Question: (Algorithms) You are given a tree represented by the following data structure. Nodes have three fields: element, parent, and auxiliary. The auxiliary field is 0
(Algorithms)You are given a tree represented by the following data structure. Nodes have three fields: element, parent, and auxiliary. The auxiliary field is 0 and is there to help during traversals. In this problem, your algorithm should leave the tree unchanged. You are given the location (or pointer to) two nodes x and y. The goal is to print the elements on the path from x to y in tree, in time proportional to the length of the path. That is, if the tree has n nodes and this path has length k, the running time of the algorithm should be (k) (O(n) is not good enough, and the tree does not have to be balanced). Argue that your algorithm indeed has running time O(k). Dont forget to bring back the tree to its original state. Present pseudocode.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
