Question: (10 points) Answer the questions about the following two algorithms about tree. The algorithm takes a tree node as input argument. The tree node contains

(10 points) Answer the questions about the following two algorithms about tree. The algorithm takes a tree node as input argument. The tree node contains fields: Left: reference of the left child Right: reference of the right child B Parent: reference of the parent Element data stored in the node Alg mystery1 (v) Input: anode in a tree Output: your job to figure out Alg mystery2 (v) Input: node in a tree Output: your job to figure out Q.enqueue (v) while Q.size> 0 do P Q. dequeue () while v.parent != null do S.push() VEV.parent while s.size() > 0 do DE S.pop() print (p.element) if p left !=null then print (p.left.element) Q.enqueue (p.left) I p.right != null then print (p.right.element) 1) What is the output of calling mystery1 (F) for the tree above? 2) Explain what is the use of stack Sin mystery10. 3) What is the output of calling mystery2(A) for the tree above? 4) Explain what is the use of queue Q in mystery 20
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
