#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
题目链接: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
算法图搜索(广度优先、深度优先)深度优先特别重要排序动态规划匹配算法和网络流算法正则表达式和字符串匹配数据结构图 (树尤其重要)Map堆栈/队列Tries | 字典树额外推荐贪婪算法概率方法近似算法算法:三路划分-快速排序合并排序(更具扩展性,复杂度类似快速排序)DF/BF 搜索 (要知道使用场景)...
分类:
编程语言 时间:
2015-04-17 11:09:01
阅读次数:
191
本文利用邻接表的方法将图进行了表示,并且利用广度优先遍历方法对图进行遍历
下面是一个图的示例:
代码如下:
#include
using namespace std;
typedef int VexType;
typedef struct Arcnode{
VexType data;
struct Arcnode *nextarc;
}ArcNode;
typedef...
分类:
编程语言 时间:
2015-04-16 21:59:52
阅读次数:
186
Binary Tree Level Order Traversal IITotal Accepted:37829Total Submissions:122499My SubmissionsQuestionSolutionGiven a binary tree, return thebottom-up...
分类:
其他好文 时间:
2015-04-16 12:23:02
阅读次数:
176
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
题目链接: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
题目链接: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
抓住那头牛(POJ3278)农夫知道一头牛的位置,想要抓住它。农夫和牛都位于数轴上,农夫起始位于点N(0#include#include#includeusing namespace std;#define MAX_SIZE 10000//查询最大的范围int visited[MAX_SIZE];/...
分类:
其他好文 时间:
2015-04-14 19:22:13
阅读次数:
115
图的深度优先遍历 和 广度 优先 遍历 算法中的 每一次 最外层 循环 都 产生 一个 无向图 的 连通分量,每一个连通分量,都可以产生一个生成树,将这些生成树合在 一起 就是 一个 森林。 用 树的 孩子 兄弟 链表 表示法 来 表示 这个 森林, 就是 这一节 算法的 内容。
深度优先森林 代码 :
//深度优先生成森林
void dfsTree(AMLGraph g,int i,Tre...
分类:
其他好文 时间:
2015-04-12 09:13:11
阅读次数:
124