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
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
BST
binary trees
invariants
iterative traversal
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported