Question bank › Binary Search Tree
Dsa Binary Search Tree Hard

Kth Smallest Element in a BST

Write a function to find the kth smallest element in a binary search tree. The input consists of two lines; the first line contains the integer k, and the second line contains the values of the BST nodes in a format where 'x' represents a null node. The values are provided in the input line as space-separated integers. Print the kth smallest element. If k is out of bounds, print 'Invalid'. Example input/output format is below. Input: 3 5 3 8 1 4 x x x x x 6 Output: 4

Key concepts

binary_search_treeinorder_traversalkth_smallest

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