Approach Summary
In-order traversal of BST visits nodes in ascending order. Count k nodes; return on the kth.
How to Recognize This Pattern
- "kth element in BST"
- In-order traversal of BST = sorted ascending
Complexity Analysis
Time Complexity
O(H + k)
Space Complexity
O(H)
Tags
Tree DFS BST Binary Tree