Dsa
Binary Search Tree
Warm-up
Inorder Successor
Given a binary search tree (BST) as a space-separated list of integers representing the inorder traversal, determine the inorder successor for a given value. If the value does not exist or has no successor, print 'None'.
Input format:
- The first line contains space-separated integers representing the inorder traversal of the BST.
- The second line contains an integer query value.
Output format:
- Print the inorder successor if present, otherwise print 'None'.
Example:
Input:
10 20 30 40 50
30
Output:
40
Key concepts
binary_search_treesuccessorinorder
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