- 1
- 0
- 约4.41千字
- 约 7页
- 2017-06-13 发布于湖北
- 举报
注:本程序主要是关于二叉树的一些基本操作,包括前序遍历,中序遍历,后序遍历以及求出总结点以及叶子结点的数目(本程序在输入时是默认以先序序列输入各个结点的数值。如果是其它方式,则三个遍历程序会有略微变化)以及哈夫曼编码的输出。
以下程序除汉字外均为在英文环境中编写,可直接复制到VC编程软件中运行。
#include stdio.h
#include stdlib.h
#include string.h
#include conio.h //getch()所需
int num;
typedef struct node //定义二叉树的结构体
{
char data;
struct node *lchild,*rchild;
}BinTNode,*BinTree;
BinTree T;
typedef struct //定义哈夫曼的结构体
{
int weight;
int parent,lchild,rchild;
}HTNode,*HuffmanTree;
HuffmanTree p;
typedef char * *HuffmanCode;
void CreateBinTree(BinTree T) //建树
{
char ch;
ch=getch();
if (ch== )
{
原创力文档

文档评论(0)