In researching complexity for any algorithm that traverses a binary search tree, I see two different ways to express the same thing:
Version #1: The traversal algorithm at worst case compares once per height of the tree; therefore complexity is O(h)
.
Version #2: The traversal algorithm at worst case compares once per height of the tree; therefore complexity is O(logN)
.
It seems to me that the same logic is at work, yet different authors use either logN
or h
. Can someone explain to me why this is the case?