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.

• When delet<strong>in</strong>g a key k, we splay the parent of the node w that gets<br />

removed, that is, w is either the node stor<strong>in</strong>g k or one of its descendents. (Recall<br />

the removal algorithm for b<strong>in</strong>ary search trees.) An example of splay<strong>in</strong>g follow<strong>in</strong>g<br />

a deletion is shown <strong>in</strong> Figure 10.18.<br />

Figure 10.18: Deletion from a splay tree: (a) the<br />

deletion of 8 from node r is performed by mov<strong>in</strong>g to r<br />

the key of the right-most <strong>in</strong>ternal node v, <strong>in</strong> the left<br />

subtree of r, delet<strong>in</strong>g v, <strong>and</strong> splay<strong>in</strong>g the parent u of v;<br />

(b) splay<strong>in</strong>g u starts with a zig-zig; (c) after the zig-zig;<br />

(d) the next step is a zig; (e) after the zig.<br />

620

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

Saved successfully!

Ooh no, something went wrong!