欢迎来到天天文库
浏览记录
ID:57239975
大小:25.00 KB
页数:7页
时间:2020-08-07
《霍夫曼编码与解码源程序java版讲课教案.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、霍夫曼编码与解码源程序java版精品文档首先是一个简单的排序importjava.util.*;publicclassHeap{ArrayListlist=newArrayList();publicHeap(){}publicHeap(E[]objects){for(inti=0;i2、);intcurrentIndex=list.size()-1;while(currentIndex>0){if((list.get(currentIndex)).compareTo(list.get(currentIndex-1))<0){Etemp=list.get(currentIndex);list.set(currentIndex,list.get(currentIndex-1));list.set(currentIndex-1,temp);}elsebreak;currentIndex--;}}publicEremove3、()//删除并返回最小的一个数据{if(list.size()==0)returnnull;EreturnObject=list.get(0);for(inti=0;i4、ffmanCode{Scannerinput=newScanner(System.in);int[]counts=newint[256];//各个字符的权重StringtransferMsg=newString();//编码后的字符串StringdecipherMsg=newString();///解码后的字符串String[]codes;publicHuffmanCode(){//System.out.println("选择何种权重值?.");useDefaultHuffmanTree();Treetree=getHuffma5、nTree(counts);codes=getCodes(tree.root);System.out.print("输出从a开始的字符的各个编码:");for(inti=0;i6、ine();//待编码的字符串System.out.print("输出输入字符串的huffman编码");for(inti=0;i7、herTMsg(){//解码//TODOAuto-generatedmethodstubintj=0;for(inti=0;i8、ls(codes[i])){decipherMsg+=(char)i;returntrue;}}returnfalse;}privatevoiduseDefaultHuffmanTree()//各个字符的权重{counts['a']=
2、);intcurrentIndex=list.size()-1;while(currentIndex>0){if((list.get(currentIndex)).compareTo(list.get(currentIndex-1))<0){Etemp=list.get(currentIndex);list.set(currentIndex,list.get(currentIndex-1));list.set(currentIndex-1,temp);}elsebreak;currentIndex--;}}publicEremove
3、()//删除并返回最小的一个数据{if(list.size()==0)returnnull;EreturnObject=list.get(0);for(inti=0;i4、ffmanCode{Scannerinput=newScanner(System.in);int[]counts=newint[256];//各个字符的权重StringtransferMsg=newString();//编码后的字符串StringdecipherMsg=newString();///解码后的字符串String[]codes;publicHuffmanCode(){//System.out.println("选择何种权重值?.");useDefaultHuffmanTree();Treetree=getHuffma5、nTree(counts);codes=getCodes(tree.root);System.out.print("输出从a开始的字符的各个编码:");for(inti=0;i6、ine();//待编码的字符串System.out.print("输出输入字符串的huffman编码");for(inti=0;i7、herTMsg(){//解码//TODOAuto-generatedmethodstubintj=0;for(inti=0;i8、ls(codes[i])){decipherMsg+=(char)i;returntrue;}}returnfalse;}privatevoiduseDefaultHuffmanTree()//各个字符的权重{counts['a']=
4、ffmanCode{Scannerinput=newScanner(System.in);int[]counts=newint[256];//各个字符的权重StringtransferMsg=newString();//编码后的字符串StringdecipherMsg=newString();///解码后的字符串String[]codes;publicHuffmanCode(){//System.out.println("选择何种权重值?.");useDefaultHuffmanTree();Treetree=getHuffma
5、nTree(counts);codes=getCodes(tree.root);System.out.print("输出从a开始的字符的各个编码:");for(inti=0;i6、ine();//待编码的字符串System.out.print("输出输入字符串的huffman编码");for(inti=0;i7、herTMsg(){//解码//TODOAuto-generatedmethodstubintj=0;for(inti=0;i8、ls(codes[i])){decipherMsg+=(char)i;returntrue;}}returnfalse;}privatevoiduseDefaultHuffmanTree()//各个字符的权重{counts['a']=
6、ine();//待编码的字符串System.out.print("输出输入字符串的huffman编码");for(inti=0;i7、herTMsg(){//解码//TODOAuto-generatedmethodstubintj=0;for(inti=0;i8、ls(codes[i])){decipherMsg+=(char)i;returntrue;}}returnfalse;}privatevoiduseDefaultHuffmanTree()//各个字符的权重{counts['a']=
7、herTMsg(){//解码//TODOAuto-generatedmethodstubintj=0;for(inti=0;i8、ls(codes[i])){decipherMsg+=(char)i;returntrue;}}returnfalse;}privatevoiduseDefaultHuffmanTree()//各个字符的权重{counts['a']=
8、ls(codes[i])){decipherMsg+=(char)i;returntrue;}}returnfalse;}privatevoiduseDefaultHuffmanTree()//各个字符的权重{counts['a']=
此文档下载收益归作者所有