麻省理工学院:《算法导论》(英文版) Lecture 16 Prof charles e. leiserson

Introduction to algorithms 6.046J/18,401J/SMA5503 Lecture 16 Prof charles e. leiserson
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 16 Prof. Charles E. Leiserson

Graphs(review) Definition. a directed graph(digraph G=(, E)is an ordered pair consisting of a set y of vertices(singular: vertex) a sete c× of edges. In an undirected graphG=(V, E), the edge set e consists of unordered pairs of vertices In either case, we have El=O(v2).Moreover if G is connected, then E2v-l, which implies that lg el=o(g n) (Review Clrs, appendix B) c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.2
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.2 Graphs (review) Definition. A directed graph (digraph) G = (V, E) is an ordered pair consisting of • a set V of vertices (singular: vertex), • a set E ⊆ V × V of edges. In an undirected graph G = (V, E), the edge set E consists of unordered pairs of vertices. In either case, we have |E| = O(V 2). Moreover, if G is connected, then |E| ≥ |V| – 1, which implies that lg |E| = Θ(lgV). (Review CLRS, Appendix B.)

Adiacencv-matrix representation The adjacency matrix of a grap oh G=(v, E), where V=(1, 2,.,n), is the matrix A[l.n,1.n gIven lif(2)∈E, 0 if(i,D) e A1234 D 10 110 0(2) storage 20010> dense 3H430000 representation 4|0010 c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.3
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.3 Adjacency-matrix representation The adjacency matrix of a graph G = (V, E), where V = {1, 2, …, n}, is the matrix A[1 . . n, 1 . . n] given by A[i, j] = 1 if (i, j) ∈ E, 0 if (i, j) ∉ E. 22 11 33 44 A 1234 1 2 3 4 0110 0010 0000 0010 Θ(V 2) storage ⇒ dense representation

Adjacency-list representation An adjacency list of a vertex E v is the list Adilv of vertices adjacent to y Ad[1]={2,3} Ady2]={3} Ady3]={} 4 Adj4]={3} For undirected graphs, Adjlvll-degree(v) For digraphs, Adilv- out-de greely Handshaking Lemma: vey=2 E for undirected graphs= adjacency lists use o(v+ E) storage a sparse representation (for either type of graph) c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.4
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.4 Adjacency-list representation An adjacency list of a vertex v ∈ V is the list Adj[v] of vertices adjacent to v. 22 11 33 44 Adj[1] = {2, 3} Adj[2] = {3} Adj[3] = {} Adj[4] = {3} For undirected graphs, |Adj[v]| = degree(v). For digraphs, |Adj[v]| = out-degree(v). Handshaking Lemma: ∑v∈V = 2|E| for undirected graphs ⇒ adjacency lists use Θ(V + E) storage — a sparse representation (for either type of graph)

Minimum spanning trees Input: A connected, undirected graph G=(V,E) with weight function w: E>R For simplicity assume that all edge weights are distinct (CLRS coVers the general case. Output: a spanning tree T-a tree that connects all vertices-of minimum weight W(7)= (l2y) (u,v)∈eT c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.5
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.5 Minimum spanning trees Input: A connected, undirected graph G = (V, E) with weight function w : E → R. • For simplicity, assume that all edge weights are distinct. (CLRS covers the general case.) ∑ ∈ = u v T w T w u v ( , ) ( ) ( , ). Output: A spanning tree T — a tree that connects all vertices — of minimum weight:

Example of Mst 6 12 14 15 10 c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.6
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.6 Example of MST 6 12 5 14 3 8 10 15 9 7

Optimal substructure MST T (Other edges ofG are not shown. Remove any edge(u, v)E T. Then, T is partitioned into two subtrees t, and t' Theorem. The subtree T, is an MST,=(V1,El the subgraph of G induced by the vertices of Ti V= vertices of t' E1={(x2y)∈E:x,y∈V1} Similarly ly for T' c 2001 by Charles E Leiserson Introduction to Agorithms Day27L16.7
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.7 u v Remove any edge Remove any edge (u, v) ∈ T. Then, T is partitioned into two subtrees T1 and T2. T1 T2 u v Optimal substructure MST T: (Other edges of G are not shown.) Theorem. The subtree T1 is an MST of G1 = (V1, E1), the subgraph of G induced by the vertices of T1: V1 = vertices of T1, E1 = { (x, y) ∈ E : x, y ∈ V1 }. Similarly for T2

Proof of optimal substructure Proof. Cut and paste ()=(l23y)+w(71)+w(72) If Ti were a lower-weight spanning tree than T, for 1, then T'=l(u,DUTUT2 would be a lower-weight spanning tree than T for G. L Do we also have overlapping subproblems? Y es Great then dynamic programming may work Yes, but MsT exhibits another powerful property which leads to an even more efficient algorithm c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.8
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.8 Proof of optimal substructure w(T) = w(u, v) + w(T1) + w(T2). Proof. Cut and paste: If T1′ were a lower-weight spanning tree than T1 for G1, then T′ = {(u, v)} ∪ T1′ ∪ T2 would be a lower-weight spanning tree than T for G. Do we also have overlapping subproblems? •Yes. Great, then dynamic programming may work! •Yes, but MST exhibits another powerful property which leads to an even more efficient algorithm

Hallmark for“ greedy” algorithms Greedy-choice property a locally optimal choice is globally optimal Theorem. Let t'be the MstofG-(v, e) and let A cv. Suppose that(u, v)E E is the least-weight edge connecting A to V-A Then,(23y)∈T c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.9
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.9 Hallmark for “greedy” algorithms Greedy-choice property A locally optimal choice is globally optimal. Theorem. Let T be the MST of G = (V, E), and let A ⊆ V. Suppose that (u, v) ∈ E is the least-weight edge connecting A to V – A. Then, (u, v) ∈ T

Proof of theorem Proof Suppose(u,v)E T. Cut and paste T ∈A d8(u, v)=least- weight edge ∈ connecting a to v-A c 2001 by Charles E Leiserson Introduction to Agorithms Day 27 L16.10
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 27 L16.10 Proof of theorem Proof. Suppose (u, v) ∉ T. Cut and paste. ∈ A ∈ V – A T: u v (u, v) = least-weight edge connecting A to V – A
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 麻省理工学院:《算法导论》(英文版) Lecture 15 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 14 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 13 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 12 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 11 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 10 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 9 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 8 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 7 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 6 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 5 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 4 Prof. charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 3 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 2 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture Prof. Charles E. Leiserson.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验二 波形输入与仿真实现.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)综合、设计性实验指导书.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)封面.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)附录GW48EDA系统使用说明.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验一 可编程ASIC使用初步.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 17 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 18 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 19 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 20 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 21 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 22 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 23 Prof charles e. leiserson.pdf
- 《计算机三级网络技术》第一章 计算机基础知识.doc
- 《计算机三级网络技术》第七章 电子商务和电子政务.doc
- 《计算机三级网络技术》第三章 局域网基础.doc
- 《计算机三级网络技术》第二章 网络基本概念.doc
- 《计算机三级网络技术》第五章 因特网基础.doc
- 《计算机三级网络技术》第八章 网络技术展望.doc
- 《计算机三级网络技术》第六章 网络安全技术.doc
- 《计算机三级网络技术》第四章 网络操作系统.doc
- 吉林师范大学:《VBA》课程电子教案(PPT教学课件)目录.ppt
- 吉林师范大学:《VBA》课程电子教案(PPT教学课件)第六章 竞赛评分模板.ppt
- 吉林师范大学:《VBA》课程电子教案(PPT教学课件)第二章 Word2002应用基础.ppt
- 吉林师范大学:《VBA》课程电子教案(PPT教学课件)第四章 VBA编程.ppt
- 吉林师范大学:《VBA》课程电子教案(PPT教学课件)第八章 成绩汇总表及数据导入模板.ppt