码迷,mamicode.com
首页 >  
搜索关键字:preorder    ( 600个结果
Leetcode[244]-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].递归遍历:/**C++ * Definition for a binary tree n...
分类:其他好文   时间:2015-06-13 11:27:51    阅读次数:143
Binary Tree Preorder Traversal
树的遍历当初觉得难死,现在还好public class Solution { public ArrayList preorderTraversal(TreeNode root) { ArrayList res = new ArrayList(); if(root=...
分类:其他好文   时间:2015-06-13 07:35:26    阅读次数:118
树的前序,中序,后序遍历(递归)
描述树的遍历即给出一个指向树的指针,访问树中的每一个节点。树的遍历有三种基本遍历方式,分别是前序(preorder)、中序(inorder)、后序(postorder)。...
分类:其他好文   时间:2015-06-12 19:28:02    阅读次数:143
剑指offer-高质量的代码(调整数组顺序使得奇数位于偶数的前面)
题目:输入一个整数数组,实现一个函数中调整该数组中数字的顺序,使得所有的奇数位于数组的前半部,所有偶数位于数组的后半部。思路:用两个指针p1和p2,分别指向数组的头和尾部,p1只向后移,p2只向前移。当满足p1using namespace std;void preorder(int* pdata,...
分类:编程语言   时间:2015-06-11 18:29:27    阅读次数:176
Binary Tree Preorder Traversal -- leetcode
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-06-05 10:14:40    阅读次数:158
Java for 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...
分类:编程语言   时间:2015-06-04 22:33:35    阅读次数:133
[LeetCode] Binary Tree Preorder Traversal
This is a fundamental and yet classic problem. I share my three solutions here:Iterative solution using stack ---O(n)time andO(n)space;Recursive solut...
分类:其他好文   时间:2015-06-03 00:46:35    阅读次数:131
[LeetCode] Flatten Binary Tree to Linked List
This problem seems to be tricky at first glance. However, if you know Morris traversal, it is just the preorder case of Morris traversal and the code ...
分类:其他好文   时间:2015-06-03 00:42:17    阅读次数:136
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 | 二叉树的前序遍历、中序遍历、后续遍历的非递归实现
Binary Tree Preorder Traversal:https://leetcode.com/problems/binary-tree-preorder-traversal/ Binary Tree Inorder Traversal :https://leetcode.com/problems/binary-tree-inorder-traversal/ Binary Tree Po...
分类:其他好文   时间:2015-06-01 22:45:30    阅读次数:137
600条   上一页 1 ... 36 37 38 39 40 ... 60 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!