Trees — Recursive traversal

Write a program that reads the description of a natural binary tree and
prints its postorder and inorder traversals.

The description of a tree consists of its traversal in preorder, which
includes the leaves marked with a -1.

For instance, the tree

[image]

would be described as
 0 7 -1 4 -1 -1 2 -1 -1 5 4 -1 -1 7 6 -1 1 -1 -1 -1 

Input

Input consists of the description of a natural binary tree.

Output

Your program must print two lines, with the postorder and inorder
traversals of the tree. Follow the format in the samples.

Problem information

Author: Unknown
Translator: Jordi Petit

Generation: 2026-02-13T10:31:07.461Z

© Jutge.org, 2006–2026.
https://jutge.org
