We can define a binary tree representation T² for an ordered general tree T as follows (see
Question:
¢ For each position p of T, there is an associated position p² of T².
¢ If p is a leaf of T, then p² in T² does not have a left child; otherwise the left child of p² is q², where q is the first child of p in T.
¢ If p has a sibling q ordered immediately after it in T, then q² is the right child of p² in T; otherwise p² does not have a right child.
Given such a representation T² of a general ordered tree T, answer each of the following questions:
a. Is a preorder traversal of T² equivalent to a preorder traversal of T?
b. Is a postorder traversal of T² equivalent to a postorder traversal of T?
c. Is an inorder traversal of T² equivalent to one of the standard traversals of T? If so, which one?
Step by Step Answer:
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser