汇总贴
题目
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, a binary tree can be uniquely determined.
Now given a sequence of statements about the structure of the resulting tree, you are supposed to tell if they are correct or not. A statment is one of the following:
- A is the root
- A and B are siblings
- A is the parent of B
- A is the left child of B
- A is the right child of B
- A and B are on the same level
- It is a full tree
Note:
- Two nodes are on the same level, means that they have the same depth.
- A full binary tree is a tree in which every node other than the leaves has two children.

该博客讨论了如何利用后序和中序遍历来重建二叉树,并针对PAT甲级考试中的1159题进行了解析。博主分享了建树的DFS方法以及如何处理不同类型的结构判断,包括根节点、兄弟节点、父子节点关系等。此外,还提供了相关题目的链接和满分代码资源。
最低0.47元/天 解锁文章
823





