Dsa
Binary Search Tree
Hard
Binary Search Tree Kth Smallest Element
Given a binary search tree and an integer k, return the k-th smallest element in it.
Input Format:
The first line contains an integer n, the number of nodes in the BST.
The second line contains n space-separated integers representing the values of the nodes.
The third line contains an integer k.
Output Format:
Print a single integer representing the k-th smallest element.
Example:
Input:
5
3 1 4 2 5
3
Output:
3
Key concepts
binary_treekth_smallestinorder_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