程序设计 - Huffman
type: channel
link: https://cxsj.yizuodi.cn/tag/Huffman/
items: Huffman coding

Huffman coding
type: item
date: 2021-11-25T16:36:00+08:00
description: 题目描述In computer science and information theory, a Huffman code is an optimal prefix code algorithm.In this exercise, please use Huffman coding to encode a given data.You should output the number of bits, denoted as B(T), to encode the data:B(T)=∑f(c)dT(c),where f(c) is the frequency of character c, and dT(c) is be the depth of character c's leaf in the tree T.输入描述The first line is the number of characters n.The following n lines, each line gives the character c and its frequency f(c).输出描述Output a single number B(T).输入样例5 0 5 1 4 2 6 3 2 4 3输出样例45参考答案CSDN 贪心算法之Huffman Code——来自Sicily