The Inorder Successor in BST II interview question is a variation where nodes have a parent pointer. You are given a specific node p, and you must find its in-order successor. Unlike the first version, you may not be given the root of the tree, so you must use the parent pointers to navigate upwards when necessary.
Companies like Meta and Microsoft use the Inorder Successor in BST II coding problem to test a candidate's comfort with non-traditional tree navigation. Having parent pointers changes the strategy and simplifies some parts while complicating others. It’s a great test of Tree interview pattern flexibility and attention to structural details.
This problem uses Parent-Pointer Traversal.
p has a right child: The successor is the leftmost node of the right subtree (same as version I).p has no right child: Move up using parent pointers until you find a node x that is the left child of its parent. That parent is the successor.null.Consider a path: Parent(10) -> Child(15) -> LeftChild(12).
12, the successor is 15 because 12 is the left child of 15.15, and it has no right child, move up to 10. If 15 was the right child of 10, keep moving up. If 10 has a parent where 10 is the left child, that's the one.When nodes have parent pointers, the tree is essentially a doubly-linked structure. Practice "going up" and "going down" logic. This is a common requirement in advanced Binary Tree interview patterns like AVL tree rotations or Red-Black tree rebalancing.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Insert into a Binary Search Tree | Medium | Solve | |
| Delete Node in a BST | Medium | Solve | |
| Search in a Binary Search Tree | Easy | Solve | |
| Convert BST to Greater Tree | Medium | Solve | |
| Inorder Successor in BST | Medium | Solve |