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

Create successful ePaper yourself

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

Table 10.4: Performance of an n-entry dictionary<br />

realized by a red-black tree, where s denotes the size<br />

of the collection returned by f<strong>in</strong>dAll. The space usage<br />

is O(n).<br />

Operation<br />

Time<br />

size, isEmpty<br />

O(1)<br />

f<strong>in</strong>d, <strong>in</strong>sert, remove<br />

O(logn)<br />

f<strong>in</strong>dAll<br />

O(logn +s)<br />

Figure 10.38: Illustrat<strong>in</strong>g the runn<strong>in</strong>g time of<br />

searches <strong>and</strong> updates <strong>in</strong> a red-black tree. The time<br />

performance is O(1) per level, broken <strong>in</strong>to a down<br />

phase, which typically <strong>in</strong>volves search<strong>in</strong>g, <strong>and</strong> an up<br />

phase, which typically <strong>in</strong>volves recolor<strong>in</strong>gs <strong>and</strong><br />

perform<strong>in</strong>g local tr<strong>in</strong>ode restructur<strong>in</strong>gs (rotations).<br />

660

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

Saved successfully!

Ooh no, something went wrong!