Class BSTree
Defined in: DataStructures.js.
Constructor Attributes | Constructor Name and Description |
---|---|
BSTree()
Class for managing a binary search tree.
|
Field Attributes | Field Name and Description |
---|---|
The root of the tree.
|
Method Attributes | Method Name and Description |
---|---|
deleteNode(node)
Deletes the node from the tree.
|
|
Returns the iterator relative to the aggregate.
|
|
insert(key, item)
Inserts the item relatives to the key value in the tree.
|
|
maximum(node)
Gets the item relatives to the maximum key stored in the tree.
|
|
minimum(node)
Gets the item relatives to the minimum key stored in the tree.
|
|
predecessor(node)
Gets the node with the key previous to the param node key.
|
|
search(key, node)
Searches the item relatives to the key.
|
|
successor(node)
Gets the node with the key next to the param node key.
|
Field Detail
root
The root of the tree.
Method Detail
{void}
deleteNode(node)
Deletes the node from the tree.
- Parameters:
- node
- {BSNode} The node to delete.
- Returns:
- {void}
{Iterator}
getIterator()
Returns the iterator relative to the aggregate.
- Returns:
- {Iterator} The iterator.
{void}
insert(key, item)
Inserts the item relatives to the key value in the tree.
- Parameters:
- key
- {number} The key to store.
- item
- {*} The item to store.
- Returns:
- {void}
{BSNode}
maximum(node)
Gets the item relatives to the maximum key stored in the tree.
- Parameters:
- node Optional, Default: root
- {Node} The node from which start the search.
- Returns:
- {BSNode} The node found.
{BSNode}
minimum(node)
Gets the item relatives to the minimum key stored in the tree.
- Parameters:
- node Optional, Default: root
- {Node} The node from which start the search.
- Returns:
- {BSNode} The node found.
{BSNode}
predecessor(node)
Gets the node with the key previous to the param node key.
- Parameters:
- node
- {BSNode} The node of which search the predecessor.
- Returns:
- {BSNode} The node found.
{*}
search(key, node)
Searches the item relatives to the key.
- Parameters:
- key
- {Number} The key to find.
- node Optional, Default: root
- {BSNode} The node from which start the search.
- Returns:
- {*} The item found or undefined if there isn't the key in the tree.
{BSNode}
successor(node)
Gets the node with the key next to the param node key.
- Parameters:
- node
- {BSNode} The node of which search the successor.
- Returns:
- {BSNode} The node found.