Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- el_bst *usun(el_bst * drzewo, el_bst *x)
- {
- el_bst *y=x->p, *z;
- if((x->left) && (x->right))
- {
- z=(rand()%2) ? usun(root, poprzednik(x)) : usun(root, nastepnik(x));
- z->left=x->left; if(z->left) z->left->p=z;
- z->right=x->right; if(z->right) z->right->p=z;
- }
- else z=(x->left) ? x->left : x->right;
- if(z) z->p=y;
- if(!y) root=z;
- else if(y->left == x) y->left =z;
- else y->right=z;
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement