-1
$\begingroup$

i only know that N is the root of the tree but there is duplicate N in this case

for example POSTORDER traversal: Y, H, E, A, N , H, O, I, T, P, N

INORDER traversal: H, Y, P, H, E, N, A, T, I, O, N

$\endgroup$
3
  • 5
    $\begingroup$ This question needs more context. We do not know which book you have in front of you. $\endgroup$ Commented Jul 31, 2024 at 9:51
  • $\begingroup$ What is a binary? Do you mean an executable file, commonly called a binary? $\endgroup$ Commented Jan 25 at 15:39
  • $\begingroup$ Do you mean a binary tree?  (‘Binary’ simply means having two of something, so a binary tree is one where each node has max. two children.) $\endgroup$ Commented Jan 25 at 19:24

2 Answers 2

0
$\begingroup$

The content of the nodes has nothing to do with the tree structure. Just replace the letters by hex digits $0_h\to A_h$

$\endgroup$
0
$\begingroup$

Trial and error, I suppose. Note there is also a duplicate H.

For a binary tree with root R and subtrees A and B, we obtain the postorder as post(A) post (B) R, and the inorder as in(A) R in(B). The sequences post(A) and in(A) are permutations of the same letters.

You can indeed infer that N is in the root of the tree because it is last in the postorder. But is it the first or second N in the inorder? If it is the first N, the subtrees would contain (H, Y, P, H, E) and (A, T, I, O, N). That would imply that the postorder also starts with a permutation of (H, Y, P, H, E) and then a permutation of (A, T, I, O, N). This is not possible, the letter P is too much at the end.

Etcetera.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.