Binary Search Tree (BST)
About
A Binary Tree in which:
The left child contains values smaller than the parent.
The right child contains values greater than the parent.
Searching an element
Inserting an element
Just look for the place that satisfy BST conditions and add.
Deleting an element
Deleting is bit more complicated and have 3 separate cases to look for:
Case 1: The deleted node has no children, so just points to
undefined.Case 2: The deleted node has only 1 child, so points to child.
Case 3: The deleted node has both children, so will point to either:
The largest decendent node of . (largest on small side)
The smallest decendent node of . (smallest on large side)
Last updated