Find kth smallest element in a binary search tree in Optimum way
Here’s just an outline of the idea: In a BST, the left subtree of node T contains only elements smaller than the value stored in T. If k is smaller than the number of elements in the left subtree, the kth smallest element must belong to the left subtree. Otherwise, if k is larger, then … Read more