Skip to main content

Kth Smallest / Largest in BST

Learn Kth Smallest / Largest in BST (Trees, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Using Inorder's Sorted Property Since inorder traversal of a BST visits nodes in ascending order, the Kth SMALLEST element is simply the Kth value visited by inorder - stop as soon as a counter reaches K, no need to traverse the whole tree.

More lessons in Trees