#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef struct node
{
int data;
struct node *lc, *rc;
} LNode, *BiTree;
int *InsertValue(BiTree b, int x)
{
if (b == NULL)
{
LNode *p = (LNode *)malloc(sizeof(LNode));
p->data = x;
p->lc = p->rc = NULL;
return 1;
}
else if (x > b->data)
{
return InsertValue(b->rc, x);
}
else if (x < b->data)
{
return InsertValue(b->lc, x);
}
else
return 0;
}
void createBST(BiTree b, int x[], int n)
{
int i = 0;
b = NULL;
while (i < n)
{
InsertValue(b, x[i]);
i++;
}
}
二叉排序树的插入,创建
最新推荐文章于 2023-05-06 00:28:43 发布