Created
Nov 16, 2025Last Modified
3 months agoBinary Search Tree
Binary Search Tree
A Binary Search Tree (BST) is a special type of binary tree.
It can be empty, but if it’s not empty, it follows these rules:
Each node contains a unique key — no duplicates.
Left subtree rule:
Every key in the left subtree is smaller than the root’s key.Right subtree rule:
Every key in the right subtree is greater than the root’s key.Recursion rule:
Both left and right subtrees must also be valid BSTs following the same properties.
Number of Comparisons (Sastry & Bhandari)
The number of comparisons required to search for a key in a BST equals the number of nodes visited until the key is found - basically, the depth/level where the key exists.
Total Number of BSTs with N Keys
The total number of distinct BSTs that can be formed using N keys is given by the Nth Catalan Number.
