Question: function TreeSuccessor(x) if x.right != NIL return TreeMinimum(x.right) // TreeMinimum is on page 291 y = x.p // parent while y != NIL and x

function TreeSuccessor(x) if x.right != NIL return TreeMinimum(x.right) // TreeMinimum is on page 291 y = x.p // parent while y != NIL and x == y.right x = y y = y.p return y 

Tree-Minimum(x)

1 While x.left != NIL

2 x = x.left

3 return x

Consider the following algorithm.

procedure MysteryWalk(x) y = TreeMinimum(x) while y != NIL print y y = TreeSuccessor(y) 

Determine what this algorithm does, and compute its running time, giving a justification for your answer.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!