🎄二叉搜索树
性质
:
每个结点的值都必须大于存储在其左子树中的任何值
每个结点的值都必须小于存储在其右子树中的任何值
🎄举例
🎄结构体创建
typedef int BstElemType;
typedef struct BinTreeSearch{
BstElemType data;
struct BinTreeSearch *leftChild;
struct BinTreeSearch *rightChild;
}BinTreeSearch;
typedef BinTreeSearch* BSTree;
🎄插入
//插入
bool BstInsert(BSTree *t, BstElemType x)
{
if (*t == NULL){
*t = (BinTreeSearch*)malloc(sizeof(BinTreeSearch));
if (*t == NULL)//内存分配是否为空
return false;
(*t)->data = x;
(*t)->leftChild = (