Please Write C++ psuedo code
Problem 2. Using the procedure TREE-SUCCESSOR and TREE-MINIMUM, write a function F(x), where x is a node in a binary search tree, to produce the output that INORDER- TREE-WALK function would produce. Determine the upper bound running time complexity of F(x) and prove its correctness.
TREE-SUCCESSOR (X) if x.right # NIL 1 2 3 4 5 6 7 return TREE-MINIMUM (x.right) y = x.p while y NIL and x == y.right x = y y = y.p return y
TREE-MINIMUM (X) while x.left # NIL x = x.left return x 1 2 3
INORDER-TREE-WALK (x) 1 if x # NIL 2 3 4 INORDER-TREE-WALK (x.left) print x.key INORDER-TREE-WALK (x.right)
Please Write C++ psuedo code
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am