文章
38
粉丝
56
获赞
67
访问
4.1k
//二叉排序树
#include <bits/stdc++.h>
using namespace std;
int m;
typedef struct node
{
int data;
struct node *lchild,*rchild;
}*BitTree;
void InsertBitTree(BitTree &T, int x) {
if (T == NULL) { // 当前子树为空,直接创建新节点
T = new node;
T->data = x;
T->lchild = T->rchild = NULL;
return;
}
if (x == T->data) return; // 重复值不插入
if (x < T->data) {
if (T->lchild == NULL) { // 左子树为空,直接创建并输出父节点值
cout << T->data << endl;
T->lchild = new node;
T->lchild->data = x;
T->lchild->lchild = T->lchild->rch...
登录后发布评论
暂无评论,来抢沙发