题目链接:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
题目:
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may ass...
分类:
其他好文 时间:
2016-05-22 12:25:16
阅读次数:
160
题目链接:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/
题目:
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may a...
分类:
其他好文 时间:
2016-05-22 12:25:05
阅读次数:
187
题目:从一棵树的前序和中序遍历结果构建一棵树。 前序遍历结果的第一个结点是树的根节点;在中序遍历结果中,根节点的左边是树的左子树,右边是树的右子树。然后再重新确定左子树和右子树的范围,递归寻找左子树和右子树的根节点。 这里需要注意的是递归终止条件:pre_start>pre_end. ...
分类:
其他好文 时间:
2016-05-08 19:53:25
阅读次数:
149
Binary Tree Inorder Traversal
Total Accepted: 123254 Total
Submissions: 310274 Difficulty: Medium
Given a binary tree, return the inorder traversal of its nodes' values.
For example...
分类:
其他好文 时间:
2016-05-07 11:28:54
阅读次数:
157
1. Recursive 2. iterative 建一个堆栈,如果是左边还有节点,那就一直走到底。 如果发现已经没有左节点了,那么就从堆栈里弹出最后一个,访问它,然后指向它的右节点(因为它的全部左节点和它本身都已经被访问过了) ...
分类:
其他好文 时间:
2016-05-04 06:35:07
阅读次数:
128
http://www.acmerblog.com/inorder-tree-traversal-without-recursion-and-without-stack-5988.html 用叶子节点的空指针来记录当前节点的位置,然后一旦遍历到了叶子节点,发现叶子节点的右指针指向的是当前节点,那么就认 ...
分类:
其他好文 时间:
2016-04-19 15:41:20
阅读次数:
176
Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, return [1,3,2]. 树的中序遍历 package leetc ...
分类:
其他好文 时间:
2016-04-19 14:15:08
阅读次数:
187