Dsa
Binary Search Tree
Warm-up
Data Archive Navigation
You are writing a navigation script for a data archive stored as a BST. Given a sequence of integers to build the tree and a target value, output the navigation instructions from the root to reach that value. Use 'L' for moving to the left child and 'R' for moving to the right child. If the target is the root, output 'ROOT'. If the target doesn't exist, output 'NOT FOUND'.
Input Format:
Line 1: Space-separated integers (insertion order).
Line 2: The target integer.
Output Format:
A string of 'L' and 'R' characters, 'ROOT', or 'NOT FOUND'.
Example:
Input:
20 10 30 5 15
15
Output:
RL
Key concepts
binary_search_treepathfindingtraversal
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