Find kth smallest element in a binary search tree in Optimum way
Posted
by Bragaadeesh
on Stack Overflow
See other posts from Stack Overflow
or by Bragaadeesh
Published on 2010-02-24T20:18:05Z
Indexed on
2010/05/13
7:04 UTC
Read the original article
Hit count: 1426
Hi,
I need to find the kth smallest element in the binary search tree without using any static/global variable. How to achieve it efficiently? The solution that I have in my mind is doing the operation in O(n), the worst case since I am planning to do an inorder traversal of the entire tree. But deep down I feel that I am not using the BST property here. Is my assumptive solution correct or is there a better one available ?
© Stack Overflow or respective owner