#include<iostream>
#include<stdlib.h>
using namespace std;
#define N 10000
typedef int Status; // Status 相当于 int
typedef int TElemType; //TElemType 相当于 int
typedef struct BiTNode{
TElemType data; //结点数据域
struct BiTNode *lchild,*rchild; //左右孩子指针
}BiTNode,*BiTree;
Status SearchBST(BiTree T,int key,BiTree f,BiTree *p) //二叉排序树的查找
{
if(!T) //查找不成功
{
*p = f;
return 0;
}
else if(T->data == key) //查找成功
{
*p = T;
return 1;
}
else if (key < T->data)
{
return SearchBST(T->lchild, key, T, p); //在左子树继续查找
}
else
{
return SearchBST(T->rchild, key, T, p); //在右子树继续查找
}
}
Status InsertBST (BiTree *T,
二叉树之二叉排序树基本操作(C++实现)
最新推荐文章于 2022-12-06 18:27:41 发布