Binary Search Trees (BST)
An Efficient Data Structure for Searching and Sorting Values
What is a Binary Search Tree (BST)?
A Binary Search Tree is a hierarchical data structure
where each node has at most two children — a left child and a right child.
For every node:
- All values in the left subtree are smaller than the node’s value.
- All values in the right subtree are larger than the node’s value.
- The left and right subtrees are also binary search trees called subtrees.
Common BST Operations
- Insert: Add a new value to the correct position.
- Search: Find whether a value is in the tree.
- Delete: Remove a value and rearrange the tree if necessary.
Visual Representation