Inorder Successor in BST II
A medium-tier problem at 61% community acceptance, tagged with Tree, Binary Search Tree, Binary Tree. Reported in interviews at Arista Networks and 0 others.
Inorder Successor in BST II is a medium-difficulty tree problem that looks simpler than it is. You're given a node in a binary search tree and need to find its inorder successor. Arista Networks asks this one. The catch: you don't have a parent pointer at first glance, but you do have access to the tree structure. Most candidates waste time trying to reconstruct parent pointers or traverse the whole tree. The real trick is recognizing what information you already have and exploiting BST properties. With a 61% acceptance rate, plenty of people get partway through and hit a wall. If you blank on the approach during your assessment, StealthCoder solves it invisibly in seconds.
Companies that ask "Inorder Successor in BST II"
Inorder Successor in BST II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe inorder successor is the next node in BST value order. If the node has a right subtree, the answer is the leftmost node in that subtree. No right subtree? You need to walk back up and find the first ancestor where your node lies in its left subtree. That's where candidates usually stumble: they either try to find parent pointers they don't have, or they traverse the entire tree looking for the answer. The BST property is your friend here. Given the node reference and the BST root (which you have access to), you can trace from root down to your target node while keeping track of potential ancestors. When you move left, that ancestor becomes a candidate successor. Clean, no extra storage, no parent pointers needed. StealthCoder handles both cases instantly and adapts to however the problem is framed.
Pattern tags
You know the problem.
Make sure you actually pass it.
Inorder Successor in BST II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Inorder Successor in BST II interview FAQ
Do I really need parent pointers for this problem?+
No. Many solutions assume parent pointers exist, but you can solve it with just the node reference and BST root. Trace from root to your node, recording ancestors as you go. That gives you all the backtracking info you need without modifying the tree structure.
What's the difference between BST successor and general tree successor?+
In a BST, you can use value ordering and structure to prune your search space. In a general tree, you'd need parent pointers or a full traversal. The BST property lets you eliminate whole branches, making the problem tractable and efficient.
Why is my brute-force inorder traversal failing on larger inputs?+
Inorder traversal works logically but wastes time visiting every node. A proper BST solution visits only nodes on the path from root to your target plus potential ancestors, cutting your runtime from O(n) to O(h) where h is height. That difference shows up fast on big, skewed trees.
Is Inorder Successor in BST II still asked at Arista Networks?+
Arista Networks is known to ask tree and BST problems. Inorder successor variants appear frequently in technical interviews. If you're interviewing there or at companies with similar backend/infrastructure roles, this pattern is worth knowing cold.
How does this relate to Binary Search Tree vs Binary Tree topics?+
The BST constraint is everything. With a plain binary tree you're stuck with traversal. With a BST you can navigate intelligently. The same node-successor question becomes trivial or hard depending on whether the tree is ordered. That's why both topics appear together here.
Want the actual problem statement? View "Inorder Successor in BST II" on LeetCode →