Dsa
Binary Search Tree
Warm-up
In-Order Successor
Given a binary search tree and a value v, find the in-order successor of the node with the value v. The in-order successor is the node with the smallest key greater than v. If v is the largest value, return -1. Input format: The first line contains an integer n (number of nodes). The next n lines each contain an integer value for the nodes in the BST. The final line contains the integer v. Output the in-order successor of v. Example: Input: 5
3
1
4
0
2
2
Output: 3
Key concepts
binary_search_treesuccessortraversal
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now