-->
当前位置:首页 > 题库

PROGRAMMING:Sequence traversal of complete binary tree

Luz5年前 (2021-05-10)题库503
A binary tree is a perfect binary tree if the number of nodes of each layer reaches the maximum. For a binary tree with depth of $$d $$and $$n $$nodes, if its nodes correspond to the first $$n $$nodes traversed by the sequence of a perfect binary tree with the same depth, such a tree is * * complete binary tree * *.
Given a complete binary tree sequence traversal, please give the tree sequence traversal results.
###Input format:
Enter the positive integer $$n $$($$Le 30 $$) in the first line, that is, the number of nodes in the tree. The second line gives a postorder traversal sequence of $$n $$positive integers no more than 100. All numbers in the same row are separated by spaces.
###Output format:
Output the sequence traversal sequence of the tree in one row. All numbers are separated by one space, and there must be no extra space at the beginning and end of the line.
###Input example:
```in
eight
91 71 2 34 10 15 55 18
```
###Output example:
```out
18 34 55 71 2 10 15 91
```







answer:If there is no answer, please comment