Kth Smallest Element in a BST
Given the root of a Binary Search Tree (BST) and an integer k, return the kth smallest value in the BST.
k is 1-indexed, meaning:
- k = 1 → smallest element
- k = 2 → second smallest element
- k = 3 → third smallest element
The important property of a BST is:
Left Subtree < Root < Right Subtree
Therefore, an inorder traversal of a BST visits values in sorted order.
Example 1
Input
root = [3,1,4,null,2] k = 1
Output
1
Explanation
Inorder traversal gives:
1 2 3 4
The 1st smallest element is:
1
Example 2
Input
root = [5,3,6,2,4,null,null,1] k = 3
Output
3
Explanation
Inorder traversal gives:
1 2 3 4 5 6
The 3rd smallest element is:
3
Constraints
Hints:
Hint 1
Use the special property of a BST.
Hint 2
An inorder traversal of a BST produces values in ascending order.
Left → Root → Right
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 12, 2026
Last updated
Aug 13, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output