DEV Community

Leo
Leo

Posted on

el



void btree::el(int x){

cout << "el " << x << endl;
node p* = r;
node *q = nullptr;
cout << " el1"";

while(p && p -> data() !=x){

    q = p;
    if(x < p ->data()){
        p = p -> left();
    }else{
        p = p -> right();
    }
}

cout << "asd";
if(!p) return;
cout << "nanana"

//hoja
if(p == nullptr){

    if(p == r) r = nullptr;
    else if (q -> left()) q -> left(nullptr);
    else q -> right();


//izquierdo

}else if(!p ->left()){

    if(p == r) r = p -> right();
    else if (q -> left()) q -> left(p -> right());
    else q -> right(p -> right());

//derecho

}else if(!p ->right()){

    if(p == r) r = p -> left();
    else if (q -> left()) q -> left(p -> left());
    else q -> right(p -> right());

//dos   
}else{
    if(p == r) r = p -> right();
    else if (q -> left()) q -> left(p -> left());
    else q -> right(p -> right());


    node *aux = p -> right();
    while(aux -> left()) aux = aux -> left();
    aux -> left(p -> left());
}

delete p;
_tamaño --;
}

Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs