照例先上题目:
1:Pre-Post-erous!
查看 提交 统计 提问
总时间限制: 1000ms 内存限制: 65536kB
描述
We are all familiar with pre-order, in-order and post-order traversals of binary trees. A common problem in data structure classes is to find the pre-order traversal of a binary tree when given the in-order and post-order traversals. Alternatively, you can find the post-order traversal when given the in-order and pre-order. However, in general you cannot determine the in-order traversal of a tree when given its pre-order and post-order traversals. Consider the four binary trees below:
a a a a
/ / \ \
b b b b
/ \ / \
c c c c
All of these trees have the same pre-order and post-order traversals. This phenomenon is not restricted to binary trees, but holds

该博客讨论了在给定先根遍历和后根遍历的情况下,如何确定m叉树的可能性。举例说明了在不同情况下,可能存在多个不同的树结构,这些树具有相同的先序和后序遍历。文章还提到了深度优先搜索(DFS)中的先根遍历和后根遍历的概念,并指出在这种情况下,无法仅凭先序和后序遍历来确定唯一的中序遍历。
最低0.47元/天 解锁文章

2155

被折叠的 条评论
为什么被折叠?



