Validate That an Address Book Index Is a Binary Search Tree
Last updated: November 29, 2026
Quick Overview
An Outlook offline address book index is supposed to be a binary search tree keyed by contact ID with no duplicates. Given its root, decide whether it truly satisfies the BST property.
Microsoft
November 29, 20260
0
0 solved
An Outlook offline address book index is supposed to be a binary search tree keyed by contact ID with no duplicates. Given its root, decide whether it truly satisfies the BST property.
A quick BST check in Microsoft phone screens. The common bug is comparing each node only with its direct children, and the interviewer will hand over a counterexample to see if the candidate fixes it.
What the Interviewer Expects
- Explain why parent and child comparison alone is insufficient
- Pass down an open interval (lo, hi) for each node
- Use strict inequalities for no duplicates
- Alternative: in-order traversal must be strictly increasing
- Avoid recursion limits on skewed trees
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Duplicates are allowed on the left only. What changes?
- Return the size of the largest subtree that is a valid BST.
- How would you validate a B-tree page instead?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: root of a binary tree of integers.
- Strict BST: all left descendants smaller, all right descendants larger.
- Output: boolean....
High-Level Design
Each node lives inside an interval set by its ancestors. The root may take any value. Going left, the upper bound becomes the parent's value; going right, the lower bound does. A node outside its inte...