码迷,mamicode.com
首页 >  
搜索关键字:广度优先搜索    ( 485个结果
图的遍历之广度优先搜索(Breadth First Search)
描述广度优先搜索算法(Breadth First Search)与树的层序遍历(level-order traversal)类似,基本思想是思想是: 从图中某顶点v出发,访问v之后,并将其访问标志置为已被访问,即visited[i]=1; 依次访问v的各个未曾访问过的邻接点; 分别从这些邻接点出发依次访问它们的邻接点,并使得“先被访问的顶点的邻接点先于后被访问的顶点的邻接点被访问,直至图中所有已被访...
分类:其他好文   时间:2015-04-17 22:22:50    阅读次数:157
leetcode_103题——Binary Tree Zigzag Level Order Traversal(广度优先搜索,队列queue,栈stack)
Binary Tree Zigzag Level Order TraversalTotal Accepted:31183Total Submissions:117840My SubmissionsQuestionSolutionGiven a binary tree, return thezigza...
分类:其他好文   时间:2015-04-17 21:53:46    阅读次数:123
leetcode_199题——Binary Tree Right Side View(广度优先搜索,队列queue)
#include#include#includeusing namespace std;// Definition for binary tree struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int...
分类:其他好文   时间:2015-04-17 21:51:07    阅读次数:141
LeetCode --- 107. Binary Tree Level Order Traversal II
题目链接: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, level by level from leaf to root). For exam...
分类:其他好文   时间:2015-04-17 18:16:21    阅读次数:176
leetcode_107题——Binary Tree Level Order Traversal II (二叉树,广度优先搜索,队列,栈)
Binary Tree Level Order Traversal IITotal Accepted:37829Total Submissions:122499My SubmissionsQuestionSolutionGiven a binary tree, return thebottom-up...
分类:其他好文   时间:2015-04-16 12:23:02    阅读次数:176
leetcode_102题——Binary Tree Level Order Traversal(二叉树,广度优先搜索,队列)
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:其他好文   时间:2015-04-16 12:08:03    阅读次数:148
LeetCode --- 103. Binary Tree Zigzag Level Order Traversal
题目链接:Binary Tree Zigzag Level Order Traversal Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and a...
分类:其他好文   时间:2015-04-16 10:24:56    阅读次数:116
LeetCode --- 102. Binary Tree Level Order Traversal
题目链接:Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#...
分类:其他好文   时间:2015-04-16 09:03:12    阅读次数:160
Catch The Caw——(广度优先搜索的应用,队列)
抓住那头牛(POJ3278)农夫知道一头牛的位置,想要抓住它。农夫和牛都位于数轴上,农夫起始位于点N(0#include#include#includeusing namespace std;#define MAX_SIZE 10000//查询最大的范围int visited[MAX_SIZE];/...
分类:其他好文   时间:2015-04-14 19:22:13    阅读次数:115
Maximum Depth of Binary Tree
求一棵树的最大深度 思路:广度优先搜索即可 class Solution {public: int maxDepth(TreeNode *root) { int depth = 0; if (!root) return depth; queue nodeQue; nodeQue.push(root)...
分类:其他好文   时间:2015-04-11 11:38:05    阅读次数:117
485条   上一页 1 ... 37 38 39 40 41 ... 49 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!