Reputation: 109
I know, time analysis of BST is O(h), where h is height of the tree.
Is it possible for a search on a BST take O(n) to complete?
Upvotes: 0
Views: 83
Reputation: 55589
Yes it is. This tree for example:
1
\
2
\
3
\
4
\
5
\
6
\
7
\
8
It takes n (8) comparisons when looking for the value 8 or greater.
Upvotes: 3