23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The cases for <strong>in</strong>sertion imply an <strong>in</strong>terest<strong>in</strong>g property for red-black trees. Namely,<br />

s<strong>in</strong>ce the Case 1 action elim<strong>in</strong>ates the double-red problem with a s<strong>in</strong>gle tr<strong>in</strong>ode<br />

restructur<strong>in</strong>g <strong>and</strong> the Case 2 action performs no restructur<strong>in</strong>g operations, at most<br />

one restructur<strong>in</strong>g is needed <strong>in</strong> a red-black tree <strong>in</strong>sertion. By the above analysis <strong>and</strong><br />

the fact that a restructur<strong>in</strong>g or recolor<strong>in</strong>g takes O(1) time, we have the follow<strong>in</strong>g:<br />

Proposition 10.10: The <strong>in</strong>sertion of a key-value entry <strong>in</strong> a red-black tree<br />

stor<strong>in</strong>g n entries can be done <strong>in</strong> O(logn) time <strong>and</strong> requires O(logn) recolor<strong>in</strong>gs <strong>and</strong><br />

one tr<strong>in</strong>ode restructur<strong>in</strong>g (a restructure operation).<br />

649

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

Saved successfully!

Ooh no, something went wrong!