Problem Description
Given a binary search tree, write a function to find the kth smallest element in the tree.
NOTE: You may assume 1 <= k <= Total number of nodes in BST
Input Format
The first argument is the root node of the binary tree.
The second argument B is an integer equal to the value of k.
Output Format
Return the value of the kth smallest node.
Example Input
Example Output
2
Example Explanation
As 2 is the second smallest element in the tree.
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 question? Checkout Sample Codes for more details.