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.

We perform a zig-zig or a zig-zag when x has a gr<strong>and</strong>parent, <strong>and</strong> we perform a zig<br />

when x has a parent but not a gr<strong>and</strong>parent. A splay<strong>in</strong>g step consists of repeat<strong>in</strong>g<br />

these restructur<strong>in</strong>gs at x until x becomes the root of T. Note that this is not the same<br />

as a sequence of simple rotations that br<strong>in</strong>gs x to the root. An example of the<br />

splay<strong>in</strong>g of a node is shown <strong>in</strong> Figures 10.15 <strong>and</strong> 10.16.<br />

Figure 10.15: Example of splay<strong>in</strong>g a node: (a) splay<strong>in</strong>g<br />

the node stor<strong>in</strong>g 14 starts with a zig-zag; (b) after the<br />

zig-zag; (c) the next step is a zig-zig. (Cont<strong>in</strong>ues <strong>in</strong><br />

Figure 10.16.)<br />

615

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

Saved successfully!

Ooh no, something went wrong!