Class BinarySearchTree<T extends Comparable<? super T>>
java.lang.Object
com.thomas.trees.BinarySearchTree<T>
- Type Parameters:
T- The type of the Node
- Direct Known Subclasses:
AVLTree
A simple implentation of a Binaray Search Tree
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes an empty Binary Search TreeBinarySearchTree(BTNode<T> node) Initializes a Binary search tree with a root node -
Method Summary
Modifier and TypeMethodDescriptionDeletes a value from a sub TreevoidDeletes a value from the treeSearches a node for a valueSearches the tree for a valueGets the minimun node of a subtreeintGets the height of the Binary Search TreegetRoot()Gets the root of the Binary Search TreeintgetSize()Gets the size of the treevoidUses in-order traversal on a NodevoidUses in-order traversal on the treevoidInserts a value into a subtreevoidInserts a node into the treevoidlevel_order(BTNode<T> node, Consumer<T> action) Uses level-order traversal on a Nodevoidlevel_order(Consumer<T> action) Uses level-order traversal on the treevoidpost_order(BTNode<T> node, Consumer<T> action) Uses post-order traversal on a Nodevoidpost_order(Consumer<T> action) Uses post-order traversal on the treevoidUses pre-order traversal on a NodevoidUses pre-order traversal on the treeintrecursiveHeight(BTNode<T> node) Recursively gets the height of the treeintrecursiveSize(BTNode<T> node) Recursively gets the size of a nodeDeletes the minimun node from a subtreevoidSets the root of the tree
-
Constructor Details
-
BinarySearchTree
public BinarySearchTree()Initializes an empty Binary Search Tree -
BinarySearchTree
-
-
Method Details
-
getRoot
-
setRoot
-
getHeight
public int getHeight()Gets the height of the Binary Search Tree- Returns:
- The height of the tree
- See Also:
-
recursiveHeight
-
getSize
public int getSize()Gets the size of the tree- Returns:
- The size of the tree
- See Also:
-
recursiveSize
-
find
-
find
-
insert
Inserts a node into the tree- Parameters:
value- The data to be inserted- See Also:
-
insert
-
delete
Deletes a value from the tree- Parameters:
value- the key to be deleted- See Also:
-
delete
-
findMin
-
removeMin
-
pre_order
-
pre_order
-
in_order
-
in_order
-
post_order
-
post_order
-
level_order
-
level_order
-