二叉排序树的查找、插入、删除

直接上代码了

struct BTNode {
    int value;
    BTNode *lchild, *rchild;
};

BTNode* recursiveSearch(BTNode *T, int value) {
    
    if (T == NULL || value == T->value)
        return T;
    if (value < T->value)
        return recursiveSearch(T->lchild, value);
    else
        return recursiveSearch(T->rchild, value);
}

BTNode* search(BTNode *T, int value) {
    
    while (T != NULL && T->value != value) {
        if (value < T->value)
            T = T->lchild;
        else
            T = T->rchild;
    }
    return T;
}

转载于:https://www.cnblogs.com/gattaca/p/6115828.html

猜你喜欢

转载自blog.csdn.net/weixin_33713707/article/details/93416189