本文利用邻接表的方法将图进行了表示,并且利用广度优先遍历方法对图进行遍历
下面是一个图的示例:
代码如下:
#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
题目链接:Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
这道题...
分类:
其他好文 时间:
2015-04-16 10:25:57
阅读次数:
123
题目链接: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
题目链接:Construct
Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the ...
分类:
其他好文 时间:
2015-04-16 10:24:42
阅读次数:
137
题目链接:Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ \
2 2
/ \ / \
3 ...
分类:
其他好文 时间:
2015-04-16 09:06:02
阅读次数:
147
题目链接: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
学校数据结构的课程实验之一。用到的数据结构:无向带权图用到的算法:Floyd最短路径算法,深度优先搜索(递归实现)需求分析: 设计一个校园导航程序,为访客提供各种信息查询服务:1.以图中各顶点表示校内各单位地点,存放单位名称,代号,简介等信息;以边表示路径,存放路径长度等相关信息。2.图中任意单位....
分类:
其他好文 时间:
2015-04-16 01:09:46
阅读次数:
148
DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 2 #include 3 #include 4 #include 5...
分类:
其他好文 时间:
2015-04-15 21:20:22
阅读次数:
206