Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int del(node *&root, node* x)
- {
- node *p, *w;
- int k = x->val;
- if ((!x->left) || (!x->right))
- p = x;
- else
- p = next(x);
- if (p->left)
- w = p->left;
- else
- w = p->right;
- if (w)
- w->up = p->up;
- if (!p->up) root = w;
- else if (p == p->up->left) p->up->left = w;
- else p->up->right = w;
- if (p != x) x->val = p->val;
- delete p;
- return k;
- }
- void modify(node*& root_1, node*& root_2, node *x_2, int cond)
- {
- if (x_2->val == cond)
- {
- add(root_1, del(root_2, next(x_2)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement