A BST is a tree where each node has at most two children, and for every node:
- Left subtree contains only values less than the node
- Right subtree contains only values greater than the node
This ordering enables efficient search by halving the search space at each step.
Operations:
insert: compare and go left/right — O(h)
search: compare and go left/right — O(h)
delete: find and restructure — O(h)
Where h = height of the tree:
Balanced tree: h = O(log n) — efficient!
Degenerate: h = O(n) — like a linked list
Applications: ordered data storage, range queries, priority queues (with balancing)
Related algorithms
Frequently asked questions
- What is Binary Search Tree (BST)?
- A BST is a tree where each node has at most two children, and for every node: - Left subtree contains only values less than the node - Right subtree contains only values greater than the node
- What is the complexity of Binary Search Tree (BST)?
- Binary Search Tree (BST) is explained with a step-by-step visualization, including time and space complexity where applicable.
- Who is this Binary Search Tree (BST) visualizer for?
- The Binary Search Tree (BST) visualization targets intermediate-level learners in the Data Structures category. Useful for students, interview prep, and hands-on review.
- What algorithms are related to Binary Search Tree (BST)?
- In the same category (Data Structures) you can explore: Stack, Queue, Linked List. Each has an interactive visualization.