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

PROGRAMMING:Strange binary tree!

Luz5年前 (2021-05-10)题库477
After this week's class, we must have our own understanding of binary tree! Recently, small Z encountered a strange binary tree, want to ask everyone's help!
This binary tree is composed of n different positive integers. It has a very important characteristic that the value of each node must be less than the value of its child nodes!
Like this:
![ 6a99f68a-6578-46e0-9232-fbf0adf3691f.jpg](~/2b8c0323-0e3c-480a-bb72-d3c4ac1e87d7.jpg)
Now small Z got a string of binary tree in order sequence, but do not know how to restore this tree, please help him!
###Input format:
The first line contains a positive integer n (n < = 50), indicating the number of nodes in the strange binary tree!
The second line contains n positive integers, representing the middle order sequence of the strange binary tree( Make sure every value is in the range of int!)
###Output format:
Output only one line, indicating the sequence sequence of strange binary tree! The sequence elements are separated by spaces, and there are no extra spaces at the end of the line!
###Input example:
Here is a set of inputs. For example:
```in
ten
8 15 3 4 1 5 12 10 18 6
```
###Output example:
The corresponding output is given here. For example:
```out
1 3 5 8 4 6 15 10 12 18
```







answer:If there is no answer, please comment