30.12.2013 Views

Red-Black tree Rotation, Insertion, Deletion

Red-Black tree Rotation, Insertion, Deletion

Red-Black tree Rotation, Insertion, Deletion

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LEFT-ROTATE(T,x)<br />

y right[x] (*Set y*)<br />

right[x] left[y] (*Turn y's left into x's right*)<br />

if lef t[y] =NIL<br />

then p[left[y]] x<br />

p[y] p[x] (*Link x's parent to y *)<br />

if p[x] =NIL<br />

then root[T ] y<br />

else if x = lef t[p[x]]<br />

then lef t[p[x]] y<br />

else right[p[x]] y<br />

lef t[y] x<br />

p[x] y<br />

Note the in-order property ispreserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!