Question: 8. (a) Using the usual alphabetic ordering, a e usual alphabetic ordering, draw the binary search tree T obtained by ing the following characters into
8. (a) Using the usual alphabetic ordering, a e usual alphabetic ordering, draw the binary search tree T obtained by ing the following characters into an empty tree in the order: K, R, P, A, W, E, G, D. (1 mark) (b) Consider the following binary tree traversal algorithm: PointerStack S 1 /S is initially empty while (true) //initially P points to the root if (P + nil) { Stack (S,P) Visit(P) P + PfLlink else { if Empty (S) return P Unstack(S) Visit(P) P PTRlink Trace the execution of the algorithm on the binary search tree T that you con- structed in part (a) and write down the orders in which the nodes are (i) stacked, (ii) unstacked, and (iii) visited. (7 marks) Do these have any relationship to any of the standard binary tree traversal orders? (2 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
