电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

算法课件Lecture12章节

37页
  • 卖家[上传人]:E****
  • 文档编号:91095409
  • 上传时间:2019-06-21
  • 文档格式:PPT
  • 文档大小:330KB
  • / 37 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、 2004 SDU,Lecture 12 Huffman Codes Problem and Catalan Number,-ordered Tree Huffman Coding Problem Algorithm and correctness Catalan Number, 2004 SDU 2,-ordered trees,A -ordered tree is a tree-like graph satisfying There is a distinguished vertex called root Each internal vertex v has at most children and each edge starting from v is labeled by a unique symbol in = 0, 1, , -1; The leaves (out-degree=0) have no children.,An example of 3-ordered tree,Each vertex v corresponds to a word: the sequen

      2、ce of symbols on the path from the root to the vertex. Example: 0, 01, 12, 2, 2004 SDU 3,-ordered trees vs prefix codes,A code C is called prefix code if no codeword in C is a prefix of some other codewords. Clearly, the leaves of a -ordered tree correspond to a prefix code, and Each prefix code can be described by a -ordered tree,Prefix Code C = 00, 01, 12, 2, 2004 SDU 4,Huffman Codes,Huffman code was proposed by David A. Huffman in 1952. A Huffman code is a prefix code, so is a uniquely decoda

      3、ble code The main application of Huffman codes is data compression, typically saving 20% to 90%. A Huffman code can be constructed from the frequencies of each source symbol., 2004 SDU 5,English Alphabet,Sym Prob Sym Prob Sym Prob Blk 0.1859 I 0.0575 R 0.0484 A 0.0642 J 0.0008 S 0.0514 B 0.0127 K 0.0049 T 0.0796 C 0.0128 L 0.0321 U 0.0228 D 0.0317 M 0.0194 V 0.0083 E 0.1031 N 0.0574 W 0.0175 F 0.0208 O 0.0632 X 0.0013 G 0.0152 P 0.0152 Y 0.0164 H 0.0467 Q 0.0008 Z 0.0005, 2004 SDU 6,The Huffman

      4、Coding Problem,Input: A set S = s1, s2, , sn of n source symbols with independent probabilities p1, p2, , pn. Output: A prefix code C = C1, C2, ,Cn for S on alphabet = 0, 1, 2, , -1 with minimum average length where li is the length of Ci. Note: This is equivalent to minimize the length of the code of the file given the source symbols. Given a file, does this method give a true shortest code?, 2004 SDU 7,Idea of Huffman Coding,Directly follow the proof of Property 2 of Kraft inequality: If a set

      5、 of integers l1, l2, ., ln satisfies the Kraft inequality, then a prefix code C = C1, C2, , Cn can be found with codeword lengths l1, l2, ., ln. The Huffman algorithm first constructs l1, l2, ., ln by the probabilities, then constructs the codes., 2004 SDU 8,Huffman Coding Procedure,Sort the probabilities in non-increasing order Combine two rightmost probabilities and insert the sum properly by keeping the order. Repeat 2 until there is only one probability left Construct a 2-ordered tree (binar

      6、y tree) according to the above procedure, 2004 SDU 9,An ExampleCombine Probabilites,Consider p = 0.6, 0.2, 0.05, 0.05, 0.03, 0.03, 0.03, 0.01 and = 0, 1.,0.6 0.2 0.05 0.05 0.03 0.03 0.03 0.01 0.6 0.2 0.05 0.05 0.04 0.03 0.03 0.6 0.2 0.06 0.05 0.05 0.04 0.6 0.2 0.09 0.06 0.05 0.6 0.2 0.11 0.09 0.6 0.2 0.2 0.6 0.4 1.0, 2004 SDU 10,An ExampleDetermine the Lengths,0.6(1) 0.2(2) 0.05(4) 0.05(4) 0.03(5) 0.03(5) 0.03(5) 0.01(5) 0.6(1) 0.2(2) 0.05(4) 0.05(4) 0.04(4) 0.03(5) 0.03(5) 0.6(1) 0.2(2) 0.06(4)

      7、 0.05(4) 0.05(4) 0.04(4) 0.6(1) 0.2(2) 0.09(3) 0.06(4) 0.05(4) 0.6(1) 0.2(2) 0.11(3) 0.09(3) 0.6(1) 0.2(2) 0.2(2) 0.6(1) 0.4(1) 1.0(0),Verify Kraft Inequality: 2-1 + 2-2 + 2-4 + 2-4 + 2-5 + 2-5 + 2-5 + 2-5 = 1, 2004 SDU 11,An ExampleConstruct the Prefix Code (Proof of Property 2),Construct C1 = 0 Construct C2 = 0, 10 Construct C4 = 0, 10, 1101, 1110 Construct C5 = 0, 10, 1101, 1110, 11000, 11001, 11110, 11111, 2004 SDU 12,An ExampleConstruct the Binary Tree (Huffman),0.6(1) 0.2(2) 0.05(4) 0.05(4

      8、) 0.03(5) 0.03(5) 0.03(5) 0.01(5) 0.6(1) 0.2(2) 0.05(4) 0.05(4) 0.04(4) 0.03(5) 0.03(5) 0.6(1) 0.2(2) 0.06(4) 0.05(4) 0.05(4) 0.04(4) 0.6(1) 0.2(2) 0.09(3) 0.06(4) 0.05(4) 0.6(1) 0.2(2) 0.11(3) 0.09(3) 0.6(1) 0.2(2) 0.2(2) 0.6(1) 0.4(1) 1.0(0), 2004 SDU 13,Huffman Algorithm for = 2,A Pseudo-code Huffman Algorithm for = 2,C corresponds to P in our case, 2004 SDU 14,Another Examplein non-decreasing order, 2004 SDU 15,Extend the Huffman Algorithm for 2,In the combination of probabilities steps, when = 2, we combine the two least probabilities into one each time. How about when 2? combine probabilities each time? if so, in the last step, there may be less than probabilities. then, the root of the -ordered tree constructed may have less than children. Is the prefix code described by the leaves of the tree optimal? i.e, with minimal average code length?, 2004 SDU

      《算法课件Lecture12章节》由会员E****分享,可在线阅读,更多相关《算法课件Lecture12章节》请在金锄头文库上搜索。

      点击阅读更多内容
    最新标签
    发车时刻表 长途客运 入党志愿书填写模板精品 庆祝建党101周年多体裁诗歌朗诵素材汇编10篇唯一微庆祝 智能家居系统本科论文 心得感悟 雁楠中学 20230513224122 2022 公安主题党日 部编版四年级第三单元综合性学习课件 机关事务中心2022年全面依法治区工作总结及来年工作安排 入党积极分子自我推荐 世界水日ppt 关于构建更高水平的全民健身公共服务体系的意见 空气单元分析 哈里德课件 2022年乡村振兴驻村工作计划 空气教材分析 五年级下册科学教材分析 退役军人事务局季度工作总结 集装箱房合同 2021年财务报表 2022年继续教育公需课 2022年公需课 2022年日历每月一张 名词性从句在写作中的应用 局域网技术与局域网组建 施工网格 薪资体系 运维实施方案 硫酸安全技术 柔韧训练 既有居住建筑节能改造技术规程 建筑工地疫情防控 大型工程技术风险 磷酸二氢钾 2022年小学三年级语文下册教学总结例文 少儿美术-小花 2022年环保倡议书模板六篇 2022年监理辞职报告精选 2022年畅想未来记叙文精品 企业信息化建设与管理课程实验指导书范本 草房子读后感-第1篇 小数乘整数教学PPT课件人教版五年级数学上册 2022年教师个人工作计划范本-工作计划 国学小名士经典诵读电视大赛观后感诵读经典传承美德 医疗质量管理制度 2 2022年小学体育教师学期工作总结 2022年家长会心得体会集合15篇
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.