题目描述 Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[1,2,3]. Note: R ...
分类:
其他好文 时间:
2018-04-09 00:28:22
阅读次数:
152
给定一棵二叉树,返回其节点值的后序遍历。例如:给定二叉树 [1,null,2,3], 1 \ 2 / 3返回 [3,2,1]。注意: 递归方法很简单,你可以使用迭代方法来解决吗?详见:https://leetcode.com/problems/binary-tree-postorder-traver ...
分类:
其他好文 时间:
2018-04-06 14:04:18
阅读次数:
162
二叉树的定义 类型名称:二叉树 数据对象集:一个有穷的结点集合。若不为空,则有根结点和其左、右二叉子树组成。 操作集:BT∈BinTree, Item∈ElementType,重要操作有: 1、Boolean IsEmpty(BinTree BT):判别BT是否为空 2、void Traversal ...
分类:
其他好文 时间:
2018-04-05 14:34:36
阅读次数:
201
给定一棵树的前序遍历与中序遍历,依据此构造二叉树。注意:你可以假设树中没有重复的元素。例如,给出前序遍历 = [3,9,20,15,7]中序遍历 = [9,3,15,20,7]返回如下的二叉树: 3 / \ 9 20 / \ 15 7详见:https://leetcode.com/problems/ ...
分类:
其他好文 时间:
2018-04-04 23:42:14
阅读次数:
399
给定一棵树的中序遍历与后序遍历,依据此构造二叉树。注意:你可以假设树中没有重复的元素。例如,给出中序遍历 = [9,3,15,20,7]后序遍历 = [9,15,7,20,3]返回如下的二叉树: 3 / \ 9 20 / \ 15 7详见:https://leetcode.com/problems/ ...
分类:
其他好文 时间:
2018-04-04 23:29:28
阅读次数:
264
给定一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶节点所在层到根节点所在的层,逐层从左向右遍历)例如:给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7返回其自自底向上的层次遍历为:[ [15,7], [9,20], [3]]详见:http ...
分类:
其他好文 时间:
2018-04-04 23:27:40
阅读次数:
317
An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the ...
分类:
其他好文 时间:
2018-04-04 20:52:47
阅读次数:
171
给定一个二叉树,返回其按层次遍历的节点值。 (即zhu'ceng'de,从左到右访问)。例如:给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7返回其层次遍历结果为:[ [3], [9,20], [15,7]]详见:https://leetcode ...
分类:
其他好文 时间:
2018-04-04 18:14:04
阅读次数:
215
给定一个二叉树,返回其节点值的锯齿形层次遍历。(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行)。例如:给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7返回锯齿形层次遍历如下:[ [3], [20,9], [15,7]]详见: ...
分类:
其他好文 时间:
2018-04-04 18:10:27
阅读次数:
168
Implement an iterative, in-order traversal of a given binary tree, return the list of keys of each node in the tree as it is in-order traversed. Examp ...
分类:
其他好文 时间:
2018-03-31 00:40:42
阅读次数:
176