欢迎来到天天文库
浏览记录
ID:46913120
大小:165.50 KB
页数:24页
时间:2019-11-29
《哈夫曼编码译码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.《数据结构》课程设计报告设计题目哈夫曼编码译码学院名称信息工程学院专业班级计算机科学与技术2班姓名学号..摘要Huffman编码是一种可变长编码方式,是二叉树的一种特殊转化形式。它的原理是:将使用次数多的代码转换成长度较短的编码,而使用次数少的可以使用较长的编码,并且保持编码的唯一可解性。本文根据Huffman编码原理,在详细设计中,根据权值和最小的根本原则,我们输入要编码的字符集及其它的权值,再根据在概要设计中提到的节点Node类,算法SuanFa类以及主类JieMian类,建立哈夫曼树,并
2、进行编码,最后输出哈夫曼编码。在完成Huffman编码后,我们利用其构建的哈夫曼编码树来进行译码。与编码过程不同,译码过程中,我们将用户输入的二进制代码串依次与字符集中的每个字符的编码进行比较,译出一个字符后,循环比较下一个字符的编码,直到所有二进制码全部译出为止。在编码和译码的过程中,我们遇到很多问题,诸如算法、语法问题,但我们都通过不断的分析,和调试将这些问题一一解决,最终建立了一个完整的编/译码系统。关键词:Huffman编码树;最优二叉树;编码;译码..AbstractHuffmanco
3、dingisaencodingofvariablelengthandaspecialtransformationformofthebinarytree.Itsprincipleis:thecodethatbeusedmoreoftenwillbechangedintothecodeofshorterlengths,whilethecodesthatbeusedlessoftencanbetransformedintothecodeoflongerlengthsandtheuniquesoluti
4、onofcodingwillbekept.AccordingtothetheoryofHuffmancoding,firstlyweenterthecharactersetwhichwillbeusedtocodingandtheirweights.Secondly,accordingtothefundanmentalprinciplethatthesumoftheweightsneedstobethesmallest,theprogramdesignsHuffmantreeinaccordan
5、cewiththeseclasswhichareinitializedintheoutlinesuchasclassNode,classSuanFa,andclassJieMian.Atlast,thecomputerwilloutputHuffmancodingonuserinterface.Andthen,weusetheHuffmancodingtreetodecodingafterthecompletionofHuffmancodingtree.Herearedifferencewith
6、encodingprocess.Wewillcomparethebinarystringthattheuserinputwiththecharactersetonebyoneduringtheprocesssofdecoding.Andthen,thecycleofthenextcharacterencodingwillcontinuewhichisbasedonthecompletionoftranslationofacharacter.Itwillbefinisheduntilalltheb
7、inarycodeistranslated.Duringtheprocessofcodinganddecoding,weencountermanyproblems,suchastheproblemonarithmeticandgrammar.However,wetryourbesttosolvetheseproblemsthroughconstantanalysisanddebugging.Eventually,weachievethegoalthatestablishacompletesyst
8、emoncodinganddecodingsuccessfully...KeyWords:Huffmancodingtree;optimalbinarytree;coding;decoding目录摘要………………………………………………………………IABSTRACT……………………………………………………II1.绪论……………………………………………………………1.1设计目的……………………………………………………11.2问题描述……………………………………………………11.3设计思想……………
此文档下载收益归作者所有