Exemplo n.º 1
0
void insert_r(BST B,node n, void *item ){
    
    if (B->compare( item,n->item) > 0) { // maggiore
        if (n->right == NULL) {
            n->right=newNode(item,n);
            return;
        }else{
            insert_r(B, n->right, item);
        }
    }else{
        if (n->left == NULL) {
            n->left = newNode(item,n);
            return;
        }else{
            insert_r(B, n->left, item);
        }
    }
}
Exemplo n.º 2
0
static node bstSerchR(BST t,node n, void *a){
    
    if (n==NULL) {
        //puts("strano nodo passato nullo");
        return NULL;
    }
    int result=t->compare(n->item, a);
    
    switch (result) {
        case 0:
            return n;
        case -1:
            return bstSerchR(t,n->right, a);
        case 1:
            return bstSerchR(t,n->left, a);
    } 
    return NULL;
}