








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth review of red-black trees and skip lists, two essential data structures used for efficient searching. Red-black trees are a type of self-balancing binary search tree, while skip lists offer a probabilistic alternative with the benefits of balanced trees. The properties, operations, and insertion techniques of red-black trees, as well as the advantages and applications of skip lists.
Typology: Slides
1 / 14
This page cannot be seen from the preview
Don't miss anything!









rbInsert(x) treeInsert(x); x->color = RED; // Move violation of #3 up tree, maintaining #4 as invariant: while (x!=root && x->p->color == RED) if (x->p == x->p->p->left) y = x->p->p->right; if (y->color == RED) x->p->color = BLACK; y->color = BLACK; x->p->p->color = RED; x = x->p->p; else // y->color == BLACK if (x == x->p->right) x = x->p; leftRotate(x); x->p->color = BLACK; x->p->p->color = RED; rightRotate(x->p->p); else // x->p == x->p->p->right (same as above, but with “right” & “left” exchanged)
rbInsert(x) treeInsert(x); x->color = RED; // Move violation of #3 up tree, maintaining #4 as invariant: while (x!=root && x->p->color == RED) if (x->p == x->p->p->left) y = x->p->p->right; if (y->color == RED) x->p->color = BLACK; y->color = BLACK; x->p->p->color = RED; x = x->p->p; else // y->color == BLACK if (x == x->p->right) x = x->p; leftRotate(x); x->p->color = BLACK; x->p->p->color = RED; rightRotate(x->p->p); else // x->p == x->p->p->right (same as above, but with “right” & “left” exchanged)
∆ ∆
if (x == x->p->right) x = x->p; leftRotate(x); // continue with case 3 code
A (^) ∆
∆ ∆ x ∆ case 2 ∆ ∆^ y
x->p->color = BLACK; x->p->p->color = RED; rightRotate(x->p->p);
∆ case 3
∆ ∆ x ∆ ∆^ y C ∆ ∆ ∆