编写一个建立二叉树的算法,要求采用二叉链表存储结构

2024-12-15 18:53:59
推荐回答(2个)
回答1:

typedef struct node
{
char data;
struct node *lchild,*rchild;
}node,*bitptr;
bitptr creat(void)
{
bitptr root;
char c;
cin

回答2:

typedef struct node
{
char data;
struct node *lchild,*rchild;
}node,*bitptr;
bitptr creat(void)
{
bitptr root;
char c;
cin>>c;

if('#' == c)
return NULL;
else
{
root = new node;
root->data = c;
root->lchild = creat();
root->rchild = creat();
}
return root;
}