I need a hint for this exercise from the CLRS Algorithms book:
Prove that no matter what node we start at in a height-h binary search tree, k suc
x
be the starting node and z
be the ending node after k
successive calls to TREE-SUCCESSOR.p
be the simple path between x
and z
inclusive.y
be the common ancestor of x
and z
that p
visits.p
is at most 2h
, which is O(h)
.output
be the elements that their values are between x.key
and z.key
inclusive.output
is O(k)
.k
successive calls to TREE-SUCCESSOR,
the nodes that are in p
are visited,
and besides the nodes x
, y
and z
,
if a sub tree of a node in p
is visited then all its elements are in output
.O(h+k)
.