码迷,mamicode.com
首页 >  
搜索关键字:preorder    ( 600个结果
二叉树的遍历javascript
三种遍历的代码: function inOrder(node){//中序遍历 if(node!=null){ inOrder(node.left); document.write(node.show()+" "); inOrder(node.right); } } function preOrder(node){//先序遍历 if(node!=null){ ...
分类:编程语言   时间:2015-05-18 09:15:22    阅读次数:175
【Tree】二叉树先序遍历 迭代 & 递归
1 /*************************** 2 https://leetcode.com/problems/binary-tree-preorder-traversal/ 3 @date 2015.5.13 4 @description 5 用非递归方法对二叉树进行先序...
分类:其他好文   时间:2015-05-16 18:19:07    阅读次数:97
【Tree】已知前序和中序遍历还原二叉树
1 /************************** 2 https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 3 @date 2015.5.16 4 @descrip....
分类:其他好文   时间:2015-05-16 18:16:24    阅读次数:167
【Construct Binary Tree from Preorder and Inorder Traversal】cpp
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.代码:/** * Def...
分类:其他好文   时间:2015-05-16 11:53:57    阅读次数:141
【Binary Tree Preorder Traversal】cpp
题目:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3]....
分类:其他好文   时间:2015-05-13 21:31:37    阅读次数:109
LeetCode: Construct Binary Tree from Preorder and Inorder Traversal
Title:Given preorder and inorder traversal of a tree, construct the binary tree.使用递归构建。/** * Definition for a binary tree node. * struct TreeNode { * ...
分类:其他好文   时间:2015-05-13 18:47:08    阅读次数:114
leetcode-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 / 3 return [1,2,3]. Note: Recursive soluti...
分类:其他好文   时间:2015-05-10 09:56:42    阅读次数:123
Construct Binary Tree from Preorder and Inorder Traversal -- leetcode
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 基本思路: 从前序和中序遍历结果,构造出一个二叉树。 前序遍历为:   根 {左子树的所有结点} {右子树所有...
分类:其他好文   时间:2015-05-07 18:59:06    阅读次数:114
144. Binary Tree Preorder Traversal
题目:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3]....
分类:其他好文   时间:2015-05-07 06:27:10    阅读次数:118
二叉树的遍历(非递归)
1. 先序遍历public void preorder(TreeNode root) { if(root == null) return; Stack stack = new Stack(); while(true) { if(root...
分类:其他好文   时间:2015-05-05 18:51:09    阅读次数:108
600条   上一页 1 ... 38 39 40 41 42 ... 60 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!