Dsa
Binary Search Tree
Medium
Kth Smallest Element in BST
Write a program to find the kth smallest element in a binary search tree. The input begins with an integer n (the number of nodes), followed by n unique integers representing the node values. Finally, a single integer k is given. Output the kth smallest element. If k is out of the bounds of the number of nodes, output 'Out of bounds'.
Example Input:
5
20
15
25
10
30
3
Example Output:
20
Key concepts
binary_search_treekth_elementinorder_traversal
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