《算法设计技巧与分析》课程教学资源(PPT讲稿)Lecture 8 贪婪法则 Greedy Approach

Lecture 8 Greedy Approach Minimum spanning tree How to design greedy algorithms
• Minimum spanning tree • How to design greedy algorithms Lecture 8 Greedy Approach

Roadmap Minimum spanning tree How to design greedy algorithms a Change-making problem a Activity selection problem n Huffman code a Knapsack problem
Roadmap • Minimum spanning tree • How to design greedy algorithms ‣ Change-making problem ‣ Activity selection problem ‣ Huffman code ‣ Knapsack problem

MST Given. Undirected graph G with positive edge weights (connected) Def. A spanning tree of G is a subgraph T that is connected and 5 16 10 10 not connected not acyclic
MST Given. Undirected graph G with positive edge weights (connected). Def. A spanning tree of G is a subgraph T that is connected and acyclic. not connected 23 10 21 14 24 16 4 18 9 7 11 8 5 6 23 10 21 14 24 16 4 18 9 7 11 8 5 6 not acyclic

Minimum spanning tree Problem: Min Spanning Input: A connected undirected graphG=(V, E)in thich each edge has a weighted lenath Output: A spanning tree of G that has minimum cost
Minimum spanning tree Problem: MinSpanning Input: A connected undirected graph G = (V , E ) in which each edge has a weighted length Output: A spanning tree of G that has minimum cost a b h c i d e g f 4 2 7 4 10 9 8 11 8 7 1 2 6 a 14 b h c i d e g f 4 2 7 4 10 9 8 11 8 7 1 2 6 14

Cut property Definition: Cut A cut (S, T s a partition of the vertex set v into two subsets s and t heorem(Cut property)Given any cut, the crossing edge of min weight is in some MST
Cut property a b h c i d e g f 4 2 7 4 10 9 8 11 8 7 1 2 6 14 Definition: Cut A cut {S,T} is a partition of the vertex set V into two subsets S and T. Theorem (Cut property)Given any cut, the crossing edge of min weight is in some MST

Correctness Theorem(GeneralMSTAlgorithm) Let a be a subset of e that is included in some mst for g let V, S-V) be any cut of G that respects A, and let(u, v) be a lightest edge crossing V,S-V. Then, auf(u, v)) is included in some MST. Theorem Kruskal algorithm and Prim algorithm correctly find a minimum cost spanning tree
Correctness Theorem Kruskal algorithm and Prim algorithm correctly find a minimum cost spanning tree

Kruskal algorithm (h,g),(ci), (@, f), (a, b), (cf), (c, d), (ig),(ih),(b,c), (a, h ), d, e),(e, (b
Kruskal algorithm a b h c i d e g f 4 2 7 4 10 9 8 11 8 7 1 2 6 14 (h,g), (c,i), (g,f), (a,b), (c,f), (c,d), (i,g), (i,h), (b,c), (a,h), (d,e), (e,f), (b,h)

Kruskal algorithm Algorithm 8.3 Kruskal Input: A weighted connected undirected graph G=(V, E)with n vertIces Output: The set of the edges T of a minimum cost spanning tree fo g 1. Sort the edges in E by nondecreasing weigh 2. for each vertex v E V do Makeset((v)) end for 3.T= 4. while T<n-1 5. Let(x,y) be the next edge in E 6. if Find(x)*Find(y)then 7. Add(x, y) to T 8. Union(x, y) end if (mlog 10. end while
Kruskal algorithm

Prim algorithm
Prim algorithm a h c i d e g f 2 7 4 10 9 8 11 8 7 1 2 6 14 4

algorithm 8.4 Prim Input: A weighted connected undirected graph G=(V,E), where Output: The set of edges T of minimum cost spanning tree for G 1.T←(}:X←{1}:y←V1(1 2.foy←2ton 3. if y is ad acent to l then 4.My+1 6. C(y)+c(1, yl 6.esec←∞ 7. end if 8. end 9.forj←1ton-1 10. Let y be such that Cly is mInimum 11.T←TU{(y,My 12.X←Xuy 13.Y←Y(y 14. for each edge(y, w)such that wEY 15. if cly, w< Cothen 6789 cw←cb,wl (n) end if end for Heap: 0(mlogn) 20. end for
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 山东大学:《计算机图形学》课程PPT教学课件(Programming with OpenGL)Part 3:Three Dimensions.ppt
- Integrated analysis of regulatoryand metabolic networks revealsnovel regulatory mechanisms inSaccharomyces cerevisiae.ppt
- 基于语义关联和信息增益的TFIDF改进算法研究.ppt
- 《C程序设计》课程PPT教学课件(电子教案)第六章 函数.ppt
- 安徽理工大学:《汇编语言》课程教学资源(PPT课件讲稿)第五章 循环与分支程序设计.ppt
- 四川大学:Object-Oriented Design and Programming(Java,PPT课件).ppt
- 《编译原理和技术》课程PPT教学课件:第十三章 函数式语言的编译.ppt
- 《Microsoft Access 2003》教程PPT:第9章 报表设计.ppt
- 北京大学远程教育:《计算机应用基础》课程PPT教学课件(专科)串讲(综合复习).pptx
- 计算机问题求解(PPT讲稿)B树.pptx
- 香港理工大学:INSTRUCTION SETS 指令.pptx
- 《计算机网络原理》课程教学资源(PPT课件讲稿)第二章 网络实现模型.ppt
- 上海交通大学:《软件开发》课程教学资源(PPT课件)第一讲 概述.ppt
- 香港浸会大学:《Data Communications and Networking》课程教学资源(PPT讲稿)Socket Programming Part II:Design of Server Software.ppt
- 中国科学技术大学:《网络算法学》课程教学资源(PPT课件)第六章 传输控制.ppt
- 西安电子科技大学:《MATLAB程序设计语言》课程教学资源(PPT讲稿)Chapter1 Matlab系统概述.ppt
- 清华大学:Mandarin Pronunciation Variation Modeling.ppt
- 清华大学出版社:《C语言程序设计》课程教学资源(PPT课件讲稿)第7章 用户自定义函数.ppt
- 中国科学技术大学:《算法基础》课程教学资源(PPT课件讲稿)第七讲 顺序统计学(主讲人:吕敏).pptx
- 《Java语言程序设计》课程教学资源(PPT课件讲稿)第三章 面向对象特征.ppt
- 山西国际商务职业学院:《网页设计与制作》课程教学资源(PPT课件)第一章 网页设计基础知识.ppt
- 《多媒体教学软件设计》课程PPT教学课件:第13章 多媒体教学软件中脚本编程技巧.ppt
- 中国科学技术大学:《计算机体系结构》课程教学资源(PPT课件讲稿)动态调度(Cont)、推断执行和ILP.ppt
- 香港浸会大学:《Experiencing Cluster Computing》Class 8 Case Studies.ppt
- 香港理工大学:Building Robust Wireless LAN for Industrial Control with DSSS-CDMA Cell Phone Network Paradigm.ppt
- International Trade Forms.ppt
- 因特网多媒体技术(PPT讲稿).ppt
- 长春工业大学:《电子商务》课程教学资源(PPT课件)第9章 网络鞋城前台页面.ppt
- 数据传送类指令(PPT讲稿).ppt
- Lower bound for sorting, radix sort.ppt
- 《ASP动态网页设计实用教程》教学资源(PPT课件讲稿)第8章 Web数据库基础.ppt
- 卷积码的概率译码(PPT讲稿).ppt
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第十章 下一代因特网.ppt
- 复旦大学:Trapping in scale-free networks with hierarchical organization of modularity.pptx
- Network and System Security Risk Assessment(PPT讲稿)Introduction.ppt
- 香港科技大学:Latent Tree Models.pptx
- 《汇编语言程序设计》课程教学资源(PPT课件讲稿)循环与分支程序设计.ppt
- ARM Tachnology:Chapter 3 STM32 Clock and Configuration.ppt
- 《软件工程简介》课程PPT教学课件(可行性研究、需求分析、总体设计、详细设计).ppt
- 利用NetRiver实验系统实现IP协议交互和TCP协议交互.ppt