文章
16
粉丝
134
获赞
0
访问
12.2k
//判断不同的输入序列是否能组成相同的二叉搜索树
#include<bits/stdc++.h>
using namespace std;
struct Tree {
int data;
struct Tree* lchild;
struct Tree* rchild;
};
void _insert(struct Tree* &root, int t) {
if(root == NULL) {
root = new Tree;
root->data = t;
root->lchild = NULL;
root->rchild = NULL;
return;
} else if(t < root->data) {
_insert(root->lchild, t);
} else if(t > root->data) {
_insert(root->rchild, t);
} else if(t == root->data)
return;
}
bool cmp(struct Tree* r1, struct Tree* r2) {
if(r1 == NULL && r2 == NULL)
return true;
if(r1 == NULL || r2 == NULL)
&...
登录后发布评论
暂无评论,来抢沙发