文章

37

粉丝

67

获赞

3

访问

8.7k

头像
二叉搜索树 题解:代码如下:请参考
P1317 浙江大学机试题
发布于2024年3月9日 20:15
阅读数 216

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

struct node {
    char data;
    struct node* left, * right;
};


struct node* insertTree(struct node* T,char x) {
    if (T == NULL) {//创建结点
        T = (struct node*)malloc(sizeof(struct node));
        T->data = x;
        T->left = NULL;
        T->right = NULL;
    }
    else {
        if (x < T->data) {
            //往左子树走
            T->left = insertTree(T->left, x);
        }
        else if (x > T->data) {
            ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发