Topic
BST interview questions
All 20 BST problems from the curated set, easiest first — a core topic for 2 of the 29 engineering roles.
- Easy
- 1
- Medium
- 17
- Hard
- 2
- Sheets
- 3
What BST is
Updated 2026-09-09A binary search tree is a binary tree that enforces a strict ordering rule at every node. Every value stored in a node's left branch must be smaller than the node itself, and every value in its right branch must be larger. Because this rule holds true everywhere down the tree, searching for a value does not require checking every branch. At each step, a single comparison lets you discard an entire half of the remaining nodes.
When to reach for it
Reach for a binary search tree when problems mention sorted tree structures, finding the kth smallest element, checking tree validity, or searching within a range of values. Signals include queries for the next greater element in a dynamic set, finding the lowest common ancestor in a sorted tree, or converting sorted arrays into height-balanced trees. When data must remain sorted while supporting continuous insertions and lookups, BST properties are the target.
How to think about it
Use the ordering property to prune entire subtrees. When looking for a key, move left if the target is smaller than the current node, or move right if it is larger, stopping when values match or when reaching a null link. For validating a tree, do not merely compare a node to its immediate children; pass valid lower and upper value bounds down through recursive calls. Walking a valid binary search tree in-order visits all values in strictly increasing numerical order.
What each operation costs
| Operation | Time |
|---|---|
| search, insert, or delete on balanced tree | O(log n) |
| search, insert, or delete on degenerate line tree | O(n) |
| in-order traversal visiting all nodes in sorted order | O(n) |
What usually goes wrong
- Validating a tree by checking only immediate children against the parent, missing violations where a node deep in the left subtree is larger than an ancestor higher up.
- Allowing duplicate values on the wrong side when the problem specification requires strictly smaller values on the left and strictly greater on the right.
- Deleting a node with two children by removing it directly instead of replacing its value with its in-order predecessor or successor and deleting that leaf instead.
Every BST problem, easiest first
- Two Sum in BSTEasy
- Validate Binary Search TreeMedium
- Lowest Common Ancestor of a BSTMedium
- Kth Smallest Element in a BSTMedium
- BST to Greater Sum TreeMedium
- Delete Node in BSTMedium
- Insert into a BSTMedium
- Recover Binary Search TreeMedium
- Floor in BSTMedium
- Ceil in BSTMedium
- Kth Largest Element in BSTMedium
- Find Kth Smallest and Largest in BSTMedium
- Construct BST from PreorderMedium
- Inorder Successor in BSTMedium
- Recover BST (Swap Nodes)Medium
- Largest BST in Binary TreeMedium
- Unique Binary Search TreesMedium
- Unique Binary Search Trees IIMedium
- Merge Two BSTsHard
- Binary Tree to DLLHard
Roles that need BST
If you are targeting one of these, BST sits early in your path rather than being optional.
Track BST in your role's order
Pick your target role and all 370 problems resequence to what that interview actually asks. Free.
Start freeBST interview questions, answered
How many BST problems should I solve for interviews?
20 curated BST problems cover the patterns interviews repeat: 1 easy, 17 medium and 2 hard. They are drawn from 3 widely used sheets, deduplicated, and ordered easiest first.
Is BST actually asked in coding interviews?
Yes, though how much depends on the role. BST is a core topic for 2 of the 29 engineering roles tracked here, including SDE / Backend Engineer, Database Engineer. For other roles it is lower frequency and belongs later in a study plan.
Which BST problem should I start with?
Start with Two Sum in BST (Easy). The list on this page is ordered easiest first for that reason, so working top to bottom builds the pattern before the harder variations arrive.
Other topics
Problem set and role mapping as of .