摘要: 重构二叉树的思路主要是首先在前序(后序)序列中找到根结点,然后在中序序列中找到根结点所在的位置,该结点将整个序列分成两个部分,前一部分为根结点的左子树元素,后一部分为根结点的右子树元素。再递归的生成左子树和右子树即可。 1.通过前序,中序序列重构二叉树 TreeNode * buildTree(ve 阅读全文
posted @ 2015-05-19 14:50 Rosanne 阅读(322) 评论(0) 推荐(0) 编辑
摘要: Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.class ... 阅读全文
posted @ 2015-05-19 13:37 Rosanne 阅读(147) 评论(0) 推荐(0) 编辑