版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、資料型態(Data Type)-程式語言的變數所能表 示的資料種類 *基本型態(Primitive Type): integer, real, boolean, character(byte) *結構化型態(Structured Type): string, array, record/structure,int i, j; char c; float r; int i110, j110; float r110; i10=20; i21=90; ,串列(List) *有序串列可以是空的()或寫成(a1, a2, ., an) 串列的表示法(representation of lists) *順
2、序對應(Sequential mapping)-array *鏈結串列(Linked list)-pointer,堆疊與佇列(Stacks otherwise make i the parent of j. *Maintain a count in the p field of the roots as a negative number. *Count field: the number of nodes in that tree.,Lemma 2.3 Assume that we start with a forest of trees, each having one node. Let
3、 T be a tree with m nodes created as a result of a sequence of unions each performed using WeightedUnion. The height of T is no greater than log m+1.,Collapsing rule: If j is a node on the path from i to its root and pirooti, then set pj to rooti.,Graph A graph G(V,E) is a structure which consists o
4、f 1. a finite nonempty set V(G) of vertices (points, nodes) 2. a (possible empty) set E(G) of edges (lines) V(G): vertex set of G E(G): edge set of G,Undirected Graph(無方向圖形): (u,v)=(v,u) *假如(u,v)E(G),則u和v是adjacent vertices, 且(u,v)是incident on u和v *Degree of a vertex: the number of edges incident to
5、that vertex G has n vertices and e edges, *A subgraph of G is a graph G(V,E),VV 且 EE *Path:假如(u,i1), (i1,i2), ., (ik,v)E,則u與v有一條 Path(路徑)存在。 *Path Length: the number of edges on the path *Simple path:路徑上除了起點和終點可能相同外,其它 的頂點都是不同的,Undirected Graph(無方向圖形): (u,v)=(v,u) *Cycle: a simple path且此路徑上的起點和終點相同
6、且(u,v)是incident on u和v *In G, two vertices u and v are said to be connected iff there is a path in G from u to v. *Connected graph:圖上每個頂點都有路徑通到其它 頂點 *Connected component: a maximal connected subgraph (圖上相連在一起的最大子圖) *Complete graph: if |V|=n then |E|=n(n-1)/2 *A tree is a connected acyclic(no cycles)
7、 graph. *Self-edge(self-loop): an edge from a vertex back to itself *Multigraph: have multiple occurrences of the same edge,Undirected Graph(無方向圖形): (u,v)=(v,u) *Eulerian walk(cycle):從任何一個頂點開始, 經過每個邊 一次,再回到原出發點 (每個頂點的degree必須是偶數) *Eulerian chain:從任一頂點開始,經過每個邊 一次,不一定要回到原點 (只有兩個頂點的degree是奇數,其它必須是 偶數),
8、Directed Graph(Digraph,有方向圖形): *假如E(G),則稱u is the tail and v the head of the edge u是adjacent to v,而v是adjacent from v 是incident to u和v *in-degree of v: the number of edges for which v is the head *out-degree of v: the number of edges for which v is the tail. *Subgraph:G=(V, E), V V 且 E E,Directed Gra
9、ph(Digraph,有方向圖形): *Directed Path:假如, , ., E, 則u與v有一條Path(路徑)存在。 *Path Length:路徑上所包含的有向邊的數目 *Simple directed path:路徑上除了起點和終點可能 相同外,其它的頂點都是不同的 *Directed Cycle(Circuit): A simple directed path 且路徑上的起點和終點相同,Directed Graph(Digraph,有方向圖形): *Strongly connected graph: for every pair of distinct vertices u
10、and v in V(G), there is a directed path from u to v and also from v to u. *Strongly connected component: a maximal subgraph that is strongly connected (有向圖上緊密相連在一起的最大有向子圖) *Complete digraph: if |V|=n then |E|=n(n-1),Graph Representations: *相鄰矩陣(adjacency matrix) *相鄰串列(adjacency list) *相鄰多元串列(adjacen
11、cy multilist),Adjacency Matrix G(V, E): a graph with n vertices A two-dimensional n*n array: a1:n, 1:n *ai, j=1 iff (i, j)E(G) *Space: O(n2) *The adjacency matrix for an undirected graph is symmetric. Use the upper or lower triangle of the matrix *For an undirected graph the degree of i is its row s
12、um. *For a directed graph the row sum is the out-degree, and the column sum is the in-degree.,Adjacency List G(V, E): a graph with n vertices and e edges *the n rows of the adjacency matrix are represented as n linked lists *There is one list for each vertex in G node: vertex, link *Each list has a
13、head node *Space: n head nodes and 2e nodes for an undirected graph n head nodes and e nodes for a directed graph Use the upper or lower triangle of the matrix *For an undirected graph the degree of i is to count the number of nodes in its adjacency list. *For a directed graph the out-degree of i is
14、 to count the number of nodes in its adjacency list.,Adjacency List Inverse adjacency lists to count the in-degree easily *One list for each vertex *Each list contains a node for each vertex adjacent to the vertex it represents.,Array node1: n+2e+1 to represent a graph G(V, E) with n vertices and e edges - eliminate the use of pointers *The nodei gives the starting point of the list for vertex i, 1in *noden+1:=n+2e+2,Orthogonal list Each node has four fields and represents one edge. Node structure: tail
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年建床前入户走访与需求沟通标准话术
- 电信业务运营与服务质量控制方案
- 环境工程专业培养方案2
- 牙齿脱落的预防
- 普通外科护理工作绩效考核
- 2026年合成酵母基因组最后几条染色体合成进展
- 2026年国聘网中国公共招聘网央企国企岗位获取攻略
- 2026年消防逃生演练培训
- 2026年消防安全知识更新
- 投标报价策略的制定方法和风险控制
- 2026年安徽国防科技职业学院单招职业技能考试题库及完整答案详解一套
- 《特大型突发地质灾害隐患点认定与核销管理办法(试行)》
- XX街道中学初中部2026年春季家长会中期筹备工作方案:筹备家长会搭建沟通平台
- 2025年时事政治必考试题库(附含答案)
- 2026年汽车制造机器人自动化率提升:趋势、技术与实践
- 第六单元联读公开课一等奖创新教学设计统编版高中语文必修下册
- 2026国家统计局桐庐调查队招聘编外工作人员1人考试参考题库及答案解析
- 作业条件危险性评价方法LEC及案例分析
- 初中英语中考短文填空题型考点精析与知识清单
- 2025年河南林业职业学院单招职业适应性考试题库附答案解析
- 2026天津宏达投资控股有限公司及所属企业招聘工作人员16人备考题库附参考答案详解(考试直接用)
评论
0/150
提交评论