Question: Implement algorithm Predecessor(x, k). For k = 1 to 20, call Predecessor (x, k) where x is the root node of the tree from Part
Implement algorithm Predecessor(x, k). For k = 1 to 20, call Predecessor (x, k) where x is the root node of the tree from Part A. Output the value of the successor of k (may be null). (in java programming)
extra:
Predecessor of a key Definition: The predecessor of a node x is the node with the largest key smaller than x.Key. TreePredecessor(x) if (x.Left!= NULL) return TreeMax(x.Left) else p = x.Parent while (p != NULL and x == p.Left) x = p p = x.Parent return p
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
