算法分析与设计Algorithms Chapter 9 贪婪技术.ppt

算法分析与设计Algorithms Chapter 9 贪婪技术.ppt

  1. 1、本文档共57页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * * * * * * * * 8 9 10 11 * 最短路径的Dijkstra算法 (1) 初始化操作 (2)若 则做:[打印S后停止],否则转(3)。 迭代 选取的节点 S DIST (1)(2)(3)(4)(5)(6)(7) 置初值 - 1 0 20 50 30 ? ? ? 1 2 1,2 0 20 45 30 ? 90 ? 2 4 1,2,4 0 20 45 30 85 90 ? 3 3 1,2,4,3 0 20 45 30 70 90 ? 4 5 1,2,4,3,5 0 20 45 30 70 80 140 5 6 1,2,4,3,5,6 0 20 45 30 70 80 130 DIST(3),DIST(Vj)+dji 即 j=1,2. i=3,4,5,6,7 DIST(3) = 50, DIST(v2)+d23=20+25=45 其他 ? DIST(Vj)+dji DIST(V7) 即 j=1,2,3,4,5,6. i=7 DIST(v1)+d17 = ? DIST(v2)+d27 = 20+? DIST(v3)+d37 = ? DIST(v4)+d47 = ? DIST(v5)+d57 = 70+70 DIST(v6)+d67 = 80+50 例 迭代 选取的节点 S DIST (1)(2)(3)(4)(5)(6)(7) 置初值 - 1 0 20 50 30 ? ? ? 1 2 1,2 0 20 45 30 ? 90 ? 2 4 1,2,4 0 20 45 30 85 90 ? 3 3 1,2,4,3 0 20 45 30 70 90 ? 4 5 1,2,4,3,5 0 20 45 30 70 80 140 5 6 1,2,4,3,5,6 0 20 45 30 70 80 130 注意路径的记录 * 哈夫曼树(Huffman Trees) 文件存储 打开新文档 * Huffman encoding The Huffman encoding algorithm is a greedy algorithm You always pick the two smallest numbers to combine Average bits/char: 0.22*2 + 0.12*3 + 0.24*2 + 0.06*4 + 0.27*2 + 0.09*4 = 2.42 The Huffman algorithm finds an optimal solution 22 12 24 6 27 9 A B C D E F 15 27 46 54 100 A=00 B=100 C=01 D=1010 E=11 F=1011 * Minimum spanning tree A minimum spanning tree is a least-cost subset of the edges of a graph that connects all the nodes Start by picking any node and adding it to the tree Repeatedly: Pick any least-cost edge from a node in the tree to a node not in the tree, and add the edge and new node to the tree Stop when all nodes have been added to the tree The result is a least-cost (3+3+2+2+2=12) spanning tree If you think some other edge should be in th

文档评论(0)

a13355589 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档