Question bank › Binary Search Tree
Dsa Binary Search Tree Medium

Inorder Successor in BST

In a binary search tree, the inorder successor of a node is the node with the smallest key greater than the node's key. Write a program that reads a BST and a specific node value, then finds and prints the inorder successor of that node. If the node has no inorder successor, print 'None'. Input Format: - The first line contains an integer N, the number of nodes in the BST. - The next N lines each contain an integer representing the node value. - The last line contains a single integer representing the target node value. Output Format: - Print the inorder successor value or 'None' if it does not exist. Example: Input: 5 20 10 30 5 15 10 Output: 15

Key concepts

binary_search_treeinorder_successorrecursion

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.