文件名称:Haffman
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:1.59kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
北邮复试上机题:赫夫曼编码
给出n个有权值的结点,构造赫夫曼树,输出所有这n个结点的权值与其赫曼编码长度(即该结点在所构造的赫曼树中的深度)的乘积的总和。
Input
第一行是一个正整数n,表示一共有n个结点。
第二行为n个整数,分别表示这n个结点的权值。
Output
输出所有这n个结点的权值与其赫曼编码长度的乘积的总和。
Sample Input
5
1 2 2 5 9
Sample Output
37-
Huffman coding
The product of the given n right nodes construct the Huffman tree, the output of all n-vertex weights and their Herman coding length (that is, the junction depth in the constructed Herman tree,). combined.
Input
The first line is a positive integer n represents a total of n nodes.
The second line of n integers, respectively, an n-vertex weights.
Output
Output of all n-vertex weights and their coding Herman length sum of the products.
Sample Input
5
12259
Sample Output
37
给出n个有权值的结点,构造赫夫曼树,输出所有这n个结点的权值与其赫曼编码长度(即该结点在所构造的赫曼树中的深度)的乘积的总和。
Input
第一行是一个正整数n,表示一共有n个结点。
第二行为n个整数,分别表示这n个结点的权值。
Output
输出所有这n个结点的权值与其赫曼编码长度的乘积的总和。
Sample Input
5
1 2 2 5 9
Sample Output
37-
Huffman coding
The product of the given n right nodes construct the Huffman tree, the output of all n-vertex weights and their Herman coding length (that is, the junction depth in the constructed Herman tree,). combined.
Input
The first line is a positive integer n represents a total of n nodes.
The second line of n integers, respectively, an n-vertex weights.
Output
Output of all n-vertex weights and their coding Herman length sum of the products.
Sample Input
5
12259
Sample Output
37
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Haffman.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.