码迷,mamicode.com
首页 >  
搜索关键字:前序遍历-非递归    ( 15个结果
树的前序遍历(非递归)
思路:将p入栈并访问p.val,遍历左子树;遍历完左子树返回时,栈顶元素应为p,出栈,再先序遍历p的右子树。代码:/** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * ...
分类:其他好文   时间:2015-12-30 00:23:06    阅读次数:212
LeetCode 94:Binary Tree Inorder Traversal(中序遍历)
Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3},1 \ 2 / 3return [1,3,2]. 题目要求对二叉树进行非递归的中序遍历,所谓前序遍历即,先访问左子树、再访问根节点、然...
分类:其他好文   时间:2015-06-01 22:47:56    阅读次数:137
LeetCode 144: Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3},1 \ 2 / 3return [1,2,3].Note: Recursive solution is trivial, could...
分类:其他好文   时间:2015-06-01 22:47:38    阅读次数:128
leetcode || 144、Binary Tree Preorder Traversal
problem: 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: Re...
分类:其他好文   时间:2015-05-05 10:36:19    阅读次数:126
Binary Tree Preorder Traversal
二叉树前序遍历非递归实现。...
分类:其他好文   时间:2014-09-01 22:49:43    阅读次数:181
15条   上一页 1 2
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!