Given a binary tree, a request sequence output of the binary tree node values,
Input format:
The first line contains an integer n (n<=50), said the tree with n vertices, numbered from 1 to n, respectively, in the number of 1 as the root node,
Line 2 to the n + 1 line, in turn, said node to node n 1, the first I + 1 (1=& lt; i<=n) line with three integers, respectively represent the node value of node I, left child node number and the right child node number, if the node I no right child nodes or left child node, then replace with 0,
The output format:
Order after the binary tree traversal of all nodes value
Sample input:
6
2, 3, 100
5-10 6
999 4 0
7 0 0
120 0 0
1 0 0
Sample output: 120-1-10 of 7, 999, 100
CodePudding user response:
CodePudding user response: