1977: Traversal of BinaryTree (pre-order traversal)
内存限制:128 MB
时间限制:1.000 S
评测方式:文本比较
命题人:
提交:7
解决:3
题目描述
The storage of the binary tree can be completed by sequential storage and chain storage. Now give you the binary tree of sequential storage, please convert it to chain storage, and then output all non-leaf nodes in the way of pre-order traversal.
输入
There are many cases, for each case,input a string to denote a binary tree(at least two nodes) stored in sequential storage. If the node is empty, use "#" instead.
输出
output all non-leaf nodes of BinaryTree in pre-order traversal
样例输入 复制
ABC
ABCDEFGHIJKL
A#B###C#######D
ABCD#EF#G
ABC#D#E##FG###H
样例输出 复制
A
ABDECF
ABC
ABDC
ABDCE