什么是哈夫曼算法

来源:百度知道 编辑:UC知道 时间:2024/06/15 12:05:27
什么是哈夫曼算法,初学者请简单易懂一些

有一种树形结构叫哈夫曼树,用哈夫曼树的方法解编程题的算法就叫哈夫曼算法,其实也没有哈夫曼算法这个专有名词了拉,你这么问我就这么跟你讲把。它产生的代码是
#include"stdio.h"
#include"stdlib.h"
#include"string.h"

typedef char ElemType;
typedef struct
{
ElemType elem;
unsigned int m_weight;
unsigned int parent,lchild,rchild;
}HTNode,*HuffmanTree;

typedef char** HuffmanCode;
typedef int Status;
typedef struct weight
{
char elem;
unsigned int m_weight;
}Weight; // save the information of the symbolizes;

void HuffmanCoding(HuffmanTree *,HuffmanCode *,Weight *,int);
void Select(HuffmanTree,int,int *,int *);
void OutputHuffmanCode(HuffmanTree,HuffmanCode,int);

Status main(void)
{
HuffmanTree HT;
HuffmanCode HC;
Weight *w;
char c; // the symbolizes;
int i,n; // the number of elements;
int wei; // the weight of a element; <