Package dsa.lab07.exercises
Class BinarySearchTree.Node<Key extends Comparable<Key>,Value> 
java.lang.Object
dsa.lab07.exercises.BinarySearchTree.Node<Key,Value> 
- Type Parameters:
- Key- the key type
- Value- the value type
- Enclosing class:
- BinarySearchTree<Key extends Comparable<Key>,- Value> 
A node in a binary search tree.
- 
Field SummaryFieldsModifier and TypeFieldDescription
- 
Constructor SummaryConstructorsConstructorDescriptionNode(BinarySearchTree.Node<Key, Value> parent, BinarySearchTree<Key, Value> tree, BinarySearchTree.Node<Key, Value> left, MapItem<Key, Value> item, BinarySearchTree.Node<Key, Value> right) 
- 
Method SummaryModifier and TypeMethodDescriptionFind the node containing the item with the given key within this subtree.Insert the given item within this subtree.max()Get the item in this subtree with the greatest key.maxNode()Get the node in this subtree with the greatest key.min()Get the item in this subtree with the least key.minNode()Get the node in this subtree with the least key.Get the item within this subtree that would be the successor of one with the given key.Get the item within this subtree that would be the predecessor of one with the given key.remove()Remove the item that this node contains from the tree, and return the node removed.
- 
Field Details- 
parent
- 
tree
- 
left
- 
item
- 
right
 
- 
- 
Constructor Details- 
Nodepublic Node(BinarySearchTree.Node<Key, Value> parent, BinarySearchTree<Key, Value> tree, BinarySearchTree.Node<Key, Value> left, MapItem<Key, Value> item, BinarySearchTree.Node<Key, Value> right) 
 
- 
- 
Method Details- 
findNodeFind the node containing the item with the given key within this subtree.- Parameters:
- key- the key
- Returns:
- the node
- Throws:
- NoSuchElementException- if no node has key- key
 
- 
insertInsert the given item within this subtree.If there's already an item with the same key, that item is replaced with this one, and that node is returned. If instead there isn't already an item with the same key, a new node is inserted and returned. - Parameters:
- item- the item
- Returns:
- the node containing the item, once inserted
 
- 
removeRemove the item that this node contains from the tree, and return the node removed.The removed node is only this node if this is a leaf. If this node isn't a leaf, find a suitable leaf node (if this has a left subtree, then its maximum node, otherwise the right subtree's minimum), copy its item into this node, and remove and return that node. - Returns:
- the removed node
 
- 
previousGet the item within this subtree that would be the predecessor of one with the given key.There may or may not be an item with the given key. - Parameters:
- key- a key
- Returns:
- the previous item (by key), or nullif there is none
 
- 
nextGet the item within this subtree that would be the successor of one with the given key.There may or may not be an item with the given key. - Parameters:
- key- a key
- Returns:
- the next item (by key), or nullif there is none
 
- 
minNodeGet the node in this subtree with the least key.- Returns:
- the minimum node (the leftmost descendant)
 
- 
maxNodeGet the node in this subtree with the greatest key.- Returns:
- the maximum node (the rightmost descendant)
 
- 
minGet the item in this subtree with the least key.- Returns:
- the minimum item (by key)
 
- 
maxGet the item in this subtree with the greatest key.- Returns:
- the maximum item (by key)
 
 
-