A JavaScript implementation of two Binary Search Tree data structures.
- Binary Search Tree
- Red-Black Tree
Click on the Live link above and use the graphical interface to see the trees in action.
The following commands are available to construct BST's. The Red-Black Tree extends the BST so all of the above functions are also available.
add
- Add a value or TreeNode
object to the BST
clear
- Resets root to null
print
- Depth-first prints the tree
find
- Locate a value (if the value is not found, locates the closest node)
deleteVal
- Locate a node with given value and deletes it if found
min
- Traverses tree for node with minimum value