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

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Kth Smallest Element In Tree on Interview Code Editor
Sign Up
to access hints and editorial solutions for Kth Smallest Element In Tree
8024 successful submissions.
Asked In:
  • Amazon
Click here to start solving coding interview questions