14.5.4 Symmetric Case |
543. <Steps 3 and 4: Symmetric case in PAVL deletion 543> = dir = q->pavl_link[0] != y; y->pavl_balance–; if (y->pavl_balance == -1) break; else if (y->pavl_balance == -2)
{ struct pavl_node *x = y->pavl_link[0]; if (x->pavl_balance == +1) {
<Right-side rebalancing case 1 in PAVL deletion 544>
} else
{
<Right-side rebalancing case 2 in PAVL deletion 545>
} }
This code is included in 539.
544. <Right-side rebalancing case 1 in PAVL deletion 544> = struct pavl_node *w; <Rebalance for + balance factor in PAVL insertion in left subtree 530> q->pavl_link[dir] = w;
This code is included in 543.
545. <Right-side rebalancing case 2 in PAVL deletion 545> = y->pavl_link[0] = x->pavl_link[1]; x->pavl_link[1] = y; x->pavl_parent = y->pavl_parent; y->pavl_parent = x; if (y->pavl_link[0] != NULL) y->pavl_link[0]->pavl_parent = y; q->pavl_link[dir] = x; if (x->pavl_balance == 0)
{ x->pavl_balance = +1; y->pavl_balance = -1; break; }
else
{ x->pavl_balance = y->pavl_balance = 0; y = x; }
This code is included in 543.