- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
《实验树和二叉树2
实验五 赫夫曼树编码基本实验:赫夫曼编码 【实验内容与要求】某通讯系统只使用8种字符a、b、c、d、e、f、g、h,在某篇电文中其使用频率分别为0.05,0.29,0.07,0.08,0.14,0.23, 0.03,0.11,设想用何种编码方式对其进行编码,能使其在进行远程通信时电文长度最短且误码率最低。【实现提示】 利用Huffman编码树求得最佳的编码方案。根据哈夫曼算法,建立哈夫曼树时,可以将哈夫曼树定义为一个结构型的一维数组HuffTree,保存哈夫曼树中各结点的信息,每个结点包括:权值、左孩子、右孩子、双亲。由于哈夫曼树中共有2n-1个结点,并且进行n-1次合并操作,所以该数组的长度为2n-1。在哈夫曼树中,设左分支为0,右分支为1,从根结点出发,遍历整棵哈夫曼树,求得各个叶子结点所表示字符的哈夫曼编码。扩展实验:实际信息传输中的Huffman编码与译码【实验内容与要求】针对一段文本(推荐为英语),就这段文本进行相应的哈夫曼编码和译码。基本要求:① 完成文本的频率统计。② 构造哈夫曼树。③ 编写编码程序和译码程序。补充实验:修理栅栏(Fence Repair)DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li ≤ 50,000) units. He then purchases a single long board just long enough to saw into the N planks (i.e., whose length is the sum of the lengths Li). FJ is ignoring the kerf, the extra length lost to sawdust when a sawcut is made; you should ignore it, too.FJ sadly realizes that he doesnt own a saw with which to cut the wood, so he mosies over to Farmer Dons Farm with this long board and politely asks if he may borrow a saw.Farmer Don, a closet capitalist, doesnt lend FJ a saw but instead offers to charge Farmer John for each of the N-1 cuts in the plank. The charge to cut a piece of wood is exactly equal to its length. Cutting a plank of length 21 costs 21 cents.Farmer Don then lets Farmer John decide the order and locations to cut the plank. Help Farmer John determine the minimum amount of money he can spend to create the N planks. FJ knows that he can cut the board in various different orders which will result in different charges since the resulting intermediate planks are of different lengths.InputLine 1: One integer N, the number of planks Lines 2..N+1: Each line contains a single integer describing the length of a needed plankOutputLine 1: One integer: the minimum amount of money he must spend to make N-1 cutsSample Input3858Sample Output34HintHe wants to cut a board of l
您可能关注的文档
最近下载
- 2025局深入贯彻精神学习教育”回头看”自查情况报告.docx VIP
- 七年级历史上册第一二单元测试题(含答案).doc VIP
- 小学语文六年级阅读理解33个常考题型满分答题公式模版技巧方法.pptx VIP
- 《物业管理》课件.pptx VIP
- 【课件】《危险化学品重大危险源监督管理暂行规定》解读.pptx VIP
- 桩基及围护技术标含施工方案.pdf VIP
- 小学写人记事类作文方法讲解(课件PPT;42页).pptx VIP
- 学校食堂餐饮服务投标方案(技术方案).doc
- 英剧剧本唐顿庄园台词本中英文对照精排版第一季第一集.pdf VIP
- [中级注册安全工程师考试密押资料]安全生产事故案例分析模拟281.docx VIP
文档评论(0)