Construction of rooted tree , please check whether my solution is correct?

811 Views Asked by At

Problem is


A rooted tree with 12 nodes has its nodes numbered 1 to 12 in pre-order. When the tree is traversed in post-order, the nodes are visited in the order 3, 5, 4, 2, 7, 8, 6, 10, 11, 12, 9, 1

Reconstruct the original tree from this information, that is, find the parent of each node, and show the tree diagrammatically.


I constructed the tree :


This is ternary tree . enter image description here


What I'm asking:

  1. Is it correct tree ?
  2. Is/Are another solution(s) possible ?
1

There are 1 best solutions below

4
On BEST ANSWER

The tree is correct and unique. The descendants of node $k$ are precisely the nodes $j\gt k$ for which $j$ appears before $k$ in post-order; that uniquely determines the tree you've drawn.