文件名称:rebuild2-3-2
介绍说明--下载内容均来自于网络,请自行研究使用
描述
一般来说,给定二叉树的先序遍历序列和后序遍历序列,并不能确定唯一确定该二叉树。
但是对于“真二叉树”(每个内部节点都有两个孩子的二叉树),给定它的先序、后序遍历序列足以完全确定它的结构。
将二叉树的n个节点用[1, n]内的整数进行编号,输入一棵真二叉树的先序、后序遍历序列,请输出它的中序遍历序列。
输入
第一行为一个整数n,即二叉树中节点的个数。
第二、三行为已知的先序、后序遍历序列。
输出
仅一行,给定真二叉树的中序遍历序列。
ps:题目来自清华大学邓俊辉老师课后PA(descr iption
In general, given the binary traversal of preorder sequences and postorder traversal sequences, it is not certain that the binary tree will be uniquely identified.
But for a "true binary tree" (a binary tree with two children per internal node), given its preorder, postorder traversal sequence is sufficient to completely determine its structure.
The n nodes of the binary tree are numbered with integers in [1, n], enter the preorder and postorder traversal sequences of a true binary tree, and then output its sequence traversal sequence.
input
The first line is an integer n, which is the number of nodes in the binary tree.
The second and third acts are known as preorder, postorder traversal sequences.
Output
Only one row, given sequence of true binary tree traversal.
ps: from PA of professor Deng Junhui's DAS lecture of Tsinghua University)
一般来说,给定二叉树的先序遍历序列和后序遍历序列,并不能确定唯一确定该二叉树。
但是对于“真二叉树”(每个内部节点都有两个孩子的二叉树),给定它的先序、后序遍历序列足以完全确定它的结构。
将二叉树的n个节点用[1, n]内的整数进行编号,输入一棵真二叉树的先序、后序遍历序列,请输出它的中序遍历序列。
输入
第一行为一个整数n,即二叉树中节点的个数。
第二、三行为已知的先序、后序遍历序列。
输出
仅一行,给定真二叉树的中序遍历序列。
ps:题目来自清华大学邓俊辉老师课后PA(descr iption
In general, given the binary traversal of preorder sequences and postorder traversal sequences, it is not certain that the binary tree will be uniquely identified.
But for a "true binary tree" (a binary tree with two children per internal node), given its preorder, postorder traversal sequence is sufficient to completely determine its structure.
The n nodes of the binary tree are numbered with integers in [1, n], enter the preorder and postorder traversal sequences of a true binary tree, and then output its sequence traversal sequence.
input
The first line is an integer n, which is the number of nodes in the binary tree.
The second and third acts are known as preorder, postorder traversal sequences.
Output
Only one row, given sequence of true binary tree traversal.
ps: from PA of professor Deng Junhui's DAS lecture of Tsinghua University)
相关搜索: c/C++
(系统自动生成,下载前可以参看下载内容)
下载文件列表
文件名 | 大小 | 更新时间 |
---|---|---|
rebuild2-3-2.cpp | 2454 | 2017-11-27 |
rebuild2-3-2\ListNode.h | 1435 | 2017-10-30 |
rebuild2-3-2\binnode.h | 10814 | 2017-11-05 |
rebuild2-3-2\list.h | 14293 | 2017-11-05 |
rebuild2-3-2\queue.h | 614 | 2017-10-30 |
rebuild2-3-2\rebuild2-3-2.cpp | 2045 | 2017-11-05 |
rebuild2-3-2\stack.h | 591 | 2017-10-30 |
rebuild2-3-2\vector.h | 13071 | 2017-10-29 |
rebuild2-3-2 |