Consider the following New-order strategy for traversing a binary tree:
- Visit the root;
- Visit the right subtree using New-order;
- Visit the left subtree using New-order;
The New-order traversal of the expression tree corresponding to the reverse polish expression
3 4 * 5 - 2 ^ 6 7 * 1 + -
is given by:
View worked solution
Answer: C
To find the New-order traversal, we first construct the expression tree from the given reverse polish (postfix) expression:
Evaluating the postfix expression yields the following binary expression tree:
- The root is the final operator:
- - The left subtree represents:
- The right subtree represents:
The New-order traversal scheme is defined as: Root Right Subtree Left Subtree.
Applying this recursively:
- At the Root:
- For the Right Subtree (root
+, left* (6, 7), right1): - For the Left Subtree (root
^, left- (T_1, 5), right2):
Combining these results gives the complete traversal:
This matches Option C.
Free practice · Your answers on this page are not saved.
