摘要: 1020 Tree Traversals (25 分) Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal seque 阅读全文
posted @ 2019-09-22 21:16 *starry* 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 后序+中序->前序 思路借鉴于伟大的柳婼小姐姐~ 由于树的后序遍历顺序是:左 右 根 树的中序遍历顺序是:左 根 右 所以后序遍历中每一段的最后位置节点就是该子树的根节点。比如对于后序遍历 3 4 2 6 5 1,1是该树的根节点。然后我们从中序遍历中找到1的位置,那么1的左边即为树的左子树,右边为 阅读全文
posted @ 2019-09-22 20:54 *starry* 阅读(855) 评论(0) 推荐(0) 编辑