1020 Tree Traversals (25 分) Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding binary tr…
题目: 思路: 这题是比较典型的树的遍历问题,思路就是将中序遍历作为位置的判断依据,假设有个节点A和它的父亲Afa,那么如果A和Afa的顺序在中序遍历中是先A后Afa,则A是Afa的左儿子,否则是右儿子. 用for遍历一遍所有的节点,让每一个节点都连接到它的父亲,最后从根节点开始访问即可. 代码: // // main.cpp // Tree // // Created by wasdns on 16/12/19. // Copyright ? 2016年 wasdns. All rights…