码迷,mamicode.com
首页 >  
搜索关键字:traversal    ( 1649个结果
Leetcode#102 Binary Tree Level Order Traversal
原题地址二叉树的层次遍历代码: 1 vector > levelOrder(TreeNode *root) { 2 vector > res; 3 queue layer; 4 5 layer.push(root); 6 ...
分类:其他好文   时间:2015-02-02 12:17:03    阅读次数:171
Leetcode#107 Binary Tree Level Order Traversal II
原题地址二叉树层次遍历,最后把遍历结果翻转一下即可代码: 1 vector > levelOrderBottom(TreeNode *root) { 2 vector > res; 3 queue layer; 4 5 layer.p...
分类:其他好文   时间:2015-02-02 12:15:00    阅读次数:209
LeetCode-Binary Tree Level Order Traversal II
题目链接:https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/ 题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, l...
分类:其他好文   时间:2015-02-01 09:37:45    阅读次数:155
[LeetCode]Binary Tree Postorder Traversal
Q:Given a binary tree, return the postorder traversal of its nodes' values. Note:Recursive solution is trivial, could you do it iteratively? 题目的意思就是不用递归求二叉树的后序遍历。 后续遍历的递归方式很简单,首先遍历左子树,然后遍历右子树,最...
分类:其他好文   时间:2015-01-31 14:49:58    阅读次数:156
94.Binary Tree Inorder Traversal(非递归中序遍历)
Given a binary tree, return the inorder traversal of itsnodes' values. For example: Given binary tree {1,#,2,3},    1         2     /    3 return [1,3,2]. Note: Recursive solution istri...
分类:其他好文   时间:2015-01-30 22:53:42    阅读次数:203
144.Binary Tree Preorder Traversal(非递归前序遍历)
Given a binary tree, return the preorder traversal of itsnodes' values. For example: Given binary tree {1,#,2,3},    1         2     /    3 return [1,2,3]. Note: Recursive solution istr...
分类:其他好文   时间:2015-01-30 22:53:36    阅读次数:234
Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. #include #include typedef struct TreeNode { int v...
分类:其他好文   时间:2015-01-30 22:50:28    阅读次数:266
深度优先搜索
深度优先搜索(DFS:Depth-First Search)是一种图搜索策略,其将搜索限制到 2 种操作:(a) 访问图中的一个节点;(b) 访问该节点的子节点。对图的深度优先搜索与对树(Tree)的深度优先遍历(Depth First Traversal)是类似的,区别在于图中可能存在环,所以可能...
分类:其他好文   时间:2015-01-30 22:28:49    阅读次数:311
c之将数组传进函数中的方法
【方法】         将数组的首地址和数组的长度传入函数中 【例如】        函数声明        void traversal(int  *array ,int    n);        函数调用        traversal (array,n); 【遍历实例】 【求最值实例】...
分类:编程语言   时间:2015-01-30 16:09:40    阅读次数:196
Leetcode#106 Construct Binary Tree from Inorder and Postorder Traversal
原题地址二叉树基本操作[ ]O[ ][ ][ ]O代码: 1 TreeNode *restore(vector &inorder, vector &postorder, int ip, int pp, int len) { 2 if (len == 0) 3 ...
分类:其他好文   时间:2015-01-30 10:36:55    阅读次数:186
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!