书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

随笔分类 -  C Huffman

Huffman和Priority_queue 解决POJ 1521
摘要:题目:http://poj.org/problem?id=1521题目大意:给定字符串,求哈夫曼编码长和它与等长编码的比值做这道题目的时候wrang了好几次,但是,经过调试之后,我彻底了解了哈夫曼树的过程说来相当有价值了。在下面我也会分享出来的。View Code #include <iostream> #include "cstdio"#include "string"#include "cstring"#include <queue> using namespace std; struct Num{ int 阅读全文

posted @ 2011-09-25 22:06 More study needed. 阅读(314) 评论(0) 推荐(0) 编辑

Huffman和Priority_queue 解决POJ 3253
摘要:DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needsN(1 ≤N≤ 20,000) planks of wood, each having some integer lengthLi(1 ≤Li≤ 50,000) units. He then purchases a single long board just long enough to saw into theNplanks (i 阅读全文

posted @ 2011-09-25 11:41 More study needed. 阅读(222) 评论(0) 推荐(0) 编辑

Huffman算法总结归纳
摘要:基本术语 哈夫曼树又称为最优树. 1、路径和路径长度 在一棵树中,从一个结点往下可以达到的孩子或子孙结点之间的通路,称为路径。 通路中分支的数目称为路径长度。若规定根结点的层数为1, 则从根结点到第L层结点的路径长度为L-1。 2、结点的权及带权路径长度 若将树中结点赋给一个有着某种含义的数值,则这个数值称为该结点的权。 结点的带权路径长度为:从根结点到该结点之间的路径长度与该结点的权的乘积。 3、树的带权路径长度 树的带权路径长度规定为所有叶子结点的带权路径长度之和,记为WPL。Huffman的构造方法 假设有n个权值,则构造出的哈夫曼树有n个叶子结点。 n个权值分... 阅读全文

posted @ 2011-09-25 10:56 More study needed. 阅读(436) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

点击右上角即可分享
微信分享提示