![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
文章平均质量分 51
Chen_chish
这个作者很懒,什么都没留下…
展开
-
[Tree]树与中序遍历
对一棵二叉树进行中序遍历得到a0 a1...an...当遍历树时,如果处理当前节点时需要其中序遍历序列中前一个节点的信息,即访问an时需要an-1那么可以用下面的框架进行中序遍历。void fun(TreeNode *root, TreeNode* &prev){ if(root == NULL) return; fun(root->left, prev); //访问当前节点并原创 2013-06-26 14:36:30 · 381 阅读 · 0 评论 -
[Tree]If you are given two traversal sequences, can you construct the binary tree?
If you are given two traversal sequences, can you construct the binary tree?August 2, 2009It depends on what traversals are given. If one of the traversal methods is Inorder then the tree转载 2013-06-24 22:12:43 · 416 阅读 · 0 评论 -
[Tree]树与先序遍历
如果我们有一个先序遍历的数组或者一个链表,以它们来建立一棵树,但是又无法很好的划分左右子树,可以用下面的框架。 TreeNode *buildTree(vector &preorder, int &cur, int min, int max) { if(cur >= preorder.size()) return NULL; TreeNode *root = NULL; if(p原创 2013-06-26 15:04:16 · 437 阅读 · 0 评论 -
[Tree]Postorder fashion&Preorder fashion
对于树来说很多操作或者处理都可以归结成Postorder fashion和Preorder fashion(top-down自顶向下的更新和button-up自底向上的更新)原创 2013-06-27 11:04:40 · 370 阅读 · 0 评论