Computer Science, asked by sirinaiduy8826, 1 year ago

The post order traversal of a binary tree is debfca. find out the pre order traversal

Answers

Answered by nniks
7
it's not possible to uniquely identify a tree just by its post order traversal
Through post order traversal, only its root node can be identify
Answered by hotelcalifornia
6

Answer:

The pre-order traversal for the given post order traversal is abdecf.

Explanation:

Step 1: Construct binary tree from the given post order traversal : debfca.

1. From the given post order traversal will identify that “a” is the root.

2. “a” being the root has a left and right side. Since left side is considered first, it is expected that it will have two sides. Hence, “a” will have “deb” on the left node and “fc” on the right.

3. Further on the left side, we understand that “b” is the root, which will have left side as “d” and right one as “e”.

4. On the right side of “a”, c will be the root which will only have a left side with “f”

5. Hence, below binary tree is constructed:

Step 2: Perform pre-order traversal of the constructed binary tree.

After traversing the above tree in the pre-order, we get: abdecf.

Attachments:
Similar questions