最优二叉检索树(哈夫曼树)编好了但不知道输入什么来测试比较好?
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
typedef struct node
{ char data;
struct node *left;
struct node *right;
}BtNode;
#define CreatBtNode(p) p=(BtNode*)malloc(sizeof(BtNode))
void FrTravel(BtNode *root)
{
if(!root)return;
putchar(root->data);
FrTravel(root->left);
FrTravel(root->right);
}
BtNode *Insert(t,s)
BtNode *s,*t;
{
BtNode *f,*p;
p=t;
while(p!=NULL)
{
f=p;
if(s->data==p->data)return t;
if(s->data<p->data)p=p->left;
else p=p->right;
}
if(t==NULL)return s;
if(s->data<f->data)f->left=s;
else f->right=s;
return t;
}
BtNode *Creat()
{
BtNode *t,*s;
int data;
t=NULL;
scanf("%d",&data);
while(data!=0)
{
s=malloc(sizeof(BtNode));
s->data=data;
s->left=NULL;
s->right=NULL;
t=Insert(t,s);
scanf("%d",&data);
}
return t;
}
void main()
{
BtNode *root,*H;
char x;
printf("Please input the node key to creat a tree:\n");
root=Creat();
printf("Please input the insert element:");
scanf("%d",&x);
CreatBtNode(H);
H->data=x;
H->left=NULL;
H->right=NULL;
Insert(root,H);
printf("Frt-root-order:");
FrTravel(root);
getch();
}
请高手来指点啊!看看输入什么数据测试比较合适?小女子不胜感激!!!