阅读背景:

PAT - 甲级 - 1127. ZigZagging on a Tree (30) ( 树的层次遍历变形 )

来源:互联网 

题目描述:

Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences. And it is a simple standard routine to print the numbers in level-order. However, if you think the problem is too simple, then you are too naive. This time you are supposed to print the numbers in "zigzagging order" -- that is, starting from the root, print the numbers level-by-level, alternating between left to right and right to left. For example, for the following tree you must output: 1 11 5 8 17 12 20 15.Suppose that all the keys in a




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: