Kth Smallest Element In Tree

Given a binary search tree, write a function to find the kth smallest element in the tree.

Example :

Input : 
  2
 / \
1   3

and k = 2

Return : 2

As 2 is the second smallest element in the tree.

NOTE : You may assume 1 <= k <= Total number of nodes in BST

Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
4729 successful submissions.
Asked In:
  • Amazon
Click here to jump start your coding interview preparation