6: Kth smallest node in a binary search tree

Given a non-empty binary search tree and integer k, find out the Kth smallest element in the tree

 

Example 1

Input: tree = 3   k = 1
             / \  
            2   8 

Output: 2

Example 2

Input: tree = 3   k = 2
             / \  
            2   8 

Output: 3