link rotR(link h) { link x = h->l; h->l = x->r; x->r = h; x->r->N = x->r->l->N + x->r->r->N + 1; x->N = x->l->N + x->r->N + 1; return x; }
link rotL(link h) { link x = h->r; h->r = x->l; x->l = h; x->l->N = x->l->l->N + x->l->r->N + 1; x->N = x->l->N + x->r->N + 1; return x; }