Trie suggestions

edit

Suggestion 1

edit
structure Node
    Children Node[Alphabet-Size]
    Value Data-Type
end structure

operation Find is
    input:  Node x and string key.
    output: The value v corresponding to the
            key key in the trie rooted at x, or
            nil if there is no such key in the x.
  
    for 0  i < length(key) do
        if x.Children[key[i]] = nil then
            return nil
        end if
        x  x.Children[key[i]]
    repeat
    return x.Value
end operation

operation Insert is
    input:  Node x, string key and value value.
    output: The trie rooted at x has been mutated
            to include the key-value pair (key, value).
            If the key key was previously present
            in x its value is changed to value.

    for 0  i < key.length do
        if x.Children[key[i]] = nil then
            x.Children[key[i]]  Create-New-Node()
        end if
        x  x.Children[key[i]]
    repeat
    x.Value  value
end operation

operation Delete is
    input:  Node x and string key.
    output: The trie rooted at x has been mutated
            to not include the key key. If the
            key key was not previously present
            in x, nothing happens. The mutated
            tree is also returned.

    if x = nil then
        return nil
    else if key = "" then
        x.Value  nil
    else
        x.Children[key[0]]  Delete(x.Children[key[0]], Remove-First-Letter(key))
    end if
    if x.Value != nil then
        return x
    end if
    for 0  i < Alphabet-Size do
        if x.Children[i] != nil then
            return x
        end if
    repeat
    return nil
end operation

Suggestion 2

edit
structure Trie
    Children    (A map from the alphabet to subtrie)
    Values      (The value at the current subtrie)
end structure

operation Find is
    input:  Trie x and string key.
    output: The value v corresponding to key key in x,
            nil if there is no such key in x.

    if key is the empty string then
        return x.Value
    end if

    head  first letter of key
    tail  key with the first letter removed
    if x.Children does not contain head then
        return nil
    end if
    return Find(x.Children[head], tail)
end operation

operation Insert is
    input:  Trie x, string key and value value.
    output: The Trie x has been mutated to include
            the key-value pair (key, value). If
            the key key was previously present in x
            its value is changed to value.

    if key is the empty string then
        x.Value  value
        return
    end if

    head  first letter of key
    tail  key with the first letter removed
    if x.Children does not contain head then
        x.Children[head]  empty Trie
    end if
    Insert(x.Children[head], tail)
end operation

operation Delete is
    input:  Trie x and string key.
    output: The Trie x has been mutated to not
            include the key key. If the key key
            was not previously present in x,
            nothing happens. The mutated tree
            is also returned.

    if key is the empty string then
        x.Value  nil
    else
        head  first letter of key
        tail  key with the first letter removed
        if x.Children does not contain head then
            return x
        else
            x.Children[head]  Delete(x.Children[head], tail)
        end if
    end if

    if x.Value is nil and x.Children is empty then
        return nil
    else
        return x
    end if
end operation

Plurisubharmonic function

edit

In mathematics, plurisubharmonic functions (sometimes abbreviated as psh, plsh, or plush functions) are class of functions used in complex analysis. All plurisubharmonic functions are subharmonic function.

Overview

edit

Definitions

edit

Properties

edit

Examples

edit

Applications

edit

Generalizations

edit

References

edit