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.

zig-zag: One of x <strong>and</strong> y is a left child <strong>and</strong> the other is a right child. (See Figure<br />

10.13.) In this case, we replace z by x <strong>and</strong> make x have y <strong>and</strong> z as its children, while<br />

ma<strong>in</strong>ta<strong>in</strong><strong>in</strong>g the <strong>in</strong>order relationships of the nodes <strong>in</strong> T.<br />

Figure 10.13: Zig-zag: (a) before; (b) after. There is<br />

another symmetric configuration where x is a right child<br />

<strong>and</strong> y is a left child.<br />

zig: x does not have a gr<strong>and</strong>parent (or we are not consider<strong>in</strong>g x's gr<strong>and</strong>parent for<br />

some reason). (See Figure 10.14.) In this case, we rotate x over y, mak<strong>in</strong>g x's<br />

children be the node y <strong>and</strong> one of x's former children w, so as to ma<strong>in</strong>ta<strong>in</strong> the<br />

relative <strong>in</strong>order relationships of the nodes <strong>in</strong> T.<br />

Figure 10.14: Zig: (a) before; (b) after. There is another<br />

symmetric configuration where x <strong>and</strong> w are left children.<br />

614

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

Saved successfully!

Ooh no, something went wrong!