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.

Justification: We use the fact (see Proposition A.1, Appendix A) that, if a<br />

> 0, b > 0, <strong>and</strong> c > a + b,<br />

loga+logb ≤ 2logc−2. (10.6)<br />

Let us consider the change <strong>in</strong> r(T) caused by each type of splay<strong>in</strong>g substep.<br />

zig-zig: (Recall Figure 10.12.) S<strong>in</strong>ce the size of each node is one more than the<br />

size of its two children, note that only the ranks of x, y, <strong>and</strong> z change <strong>in</strong> a zig-zig<br />

operation, where y is the parent of x <strong>and</strong> z is the parent of y. Also,<br />

Note that n(x)+n ′(z) ≤ n ′(x). Thus, by 10.6, r(x)+r ′(z) ≤ 2r ′(x)−2, that is,<br />

r ′(z) ≤ 2r ′(x)−r(x)−2.<br />

This <strong>in</strong>equality <strong>and</strong> 10.7 imply<br />

δ ≤ r ′(x)+(2r ′(x)−r(x)−2)−2r(x)<br />

≤ 3(r ′(x)−r(x))−2.<br />

zig-zag: (Recall Figure 10.13.) Aga<strong>in</strong>, by the def<strong>in</strong>ition of size <strong>and</strong> rank, only the<br />

ranks of x, y, <strong>and</strong> z change, where y denotes the parent of x <strong>and</strong> z denotes the<br />

parent of y. Also, r ′(x) = r(z) <strong>and</strong> r(x) ≤ r(y). Thus<br />

δ = r ′{x) + r ′{y) + r ′{z)−r{x)−r{y)−r{z)<br />

≤ r ′(y) + r ′(z)−r(x)−r(y)<br />

≤ r ′(y) + r ′(z)−2r(x). (10.8)<br />

Note that n ′(y) + n ′(z) ≤ n ′(x); hence, by 10.6, r ′(y)+r ′(z) ≤ 2r ′(x) −2. Thus,<br />

δ ≤ 2r ′(x)−2−2r(x)<br />

≤ 3(r ′(x)−r(x))−2.<br />

zig: (Recall Figure 10.14.) In this case, only the ranks of x <strong>and</strong> y change, where y<br />

denotes the parent of x. Also, r ′(y) ≤ r(y) <strong>and</strong> r ′(x) ≥ r(x). Thus<br />

δ = r ′(y)+r ′(x)−r(y)−r(x)<br />

624

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

Saved successfully!

Ooh no, something went wrong!