- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Assignment 2 (Due at 1030 a.m on Friday of Week 10).ppt
Hash Tables Dictionaries Assignment 2: (Due at 10:30 a.m on Friday of Week 10) Review of Lecture 1 to Lecture 6 Lecture 2: Lecture 4: Tree Lecture 5: More on Trees Lecture 6: Priority Queue (Heeps) Lecture 6: Priority Queue (Heeps) Huffman codes (Page 565 Chapter 12.4) Binary character code: each character is represented by a unique binary string. A data file can be coded in two ways: Variable-length code Need some care to read the code. 001011101 (codeword: a=0, b=00, c=01, d=11.) Where to cut? 00 can be explained as either aa or b. Prefix of 0011: 0, 00, 001, and 0011. Prefix codes: no codeword is a prefix of some other codeword. (prefix free) Prefix codes are simple to encode and decode. Using codeword in Table to encode and decode Encode: abc = 0.101.100 = 0101100 (just concatenate the codewords.) Decode: 001011101 = 0.0.101.1101 = aabe Encode: abc = 0.101.100 = 0101100 (just concatenate the codewords.) Decode: 001011101 = 0.0.101.1101 = aabe (use the (right)binary tree below:) Binary tree Every nonleaf node has two children. The fixed-length code in our example is not optimal. The total number of bits required to encode a file is f ( c ) : the frequency (number of occurrences) of c in the file dT(c): denote the depth of c’s leaf in the tree Constructing an optimal code Formal definition of the problem: Input: a set of characters C={c1, c2, …, cn}, each c?C has frequency f[c]. Output: a binary tree representing codewords so that the total number of bits required for the file is minimized. Huffman proposed a greedy algorithm to solve the problem. The Huffman Algorithm This algorithm builds the tree T corresponding to the optimal code in a bottom-up manner. C is a set of n characters, and each character c in C is a character with a defined frequency f[c]. Q is a priority queue, keyed on f, used to identify the two least-frequent characters to merge together. The result of the merger is a new object (internal node) whose frequency is the sum o
您可能关注的文档
- 09年英语中考命题及改卷体会 漳州三中 江红.ppt
- 10 MONEY AND PRICES IN THE LONG RUN.ppt
- 10市民社会理论.ppt-SOCⅠ130099.1西方社会思想史.ppt
- 111-新形势下工商系统参与社会管理创新的思考.ppt
- 15.1 编写简单的程序.ppt
- 175586 Tsou.ppt
- 2.5万吨年正庚烯装置生产流程设计.ppt
- 2013年下半年四川省考公告解读.ppt
- 21-30 October 2008.ppt
- 30 days has September,April, June and November,All the r.ppt
- ATI Technical Assistance WorkshopOctober 30, 2006.ppt
- AT的早期筛查与检查指标.ppt
- Avoiding Run-on Sentences, Comma Splices, and Fragments.ppt
- Basic Life SupportCPR.PPT
- Bethesda,MD,30.3.2004.ppt
- Bill Krueger.ppt
- Bioenergy Policies.ppt
- Biogen Idec Acquisition ThesisNovember 30, 2007.ppt
- Bone Marrow Transplantation.ppt
- BPO Business Process Outsourcing.ppt
文档评论(0)