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.

Def<strong>in</strong>ition of an (a,b) Tree<br />

An (a,b) tree, where a <strong>and</strong> b are <strong>in</strong>tegers, such that 2 ≤ a ≤ (b + 1)/2, is a<br />

multiway search tree T with the follow<strong>in</strong>g additional restrictions:<br />

Size Property: Each <strong>in</strong>ternal node has at least a children, unless it is the root, <strong>and</strong><br />

has at most b children.<br />

Depth Property: All the external nodes have the same depth.<br />

Proposition 14.1: The height of an (a, b) tree stor<strong>in</strong>g n entries is (log<br />

n/log b) <strong>and</strong> O(log n/log a).<br />

Justification: Let T be an (a, b) tree stor<strong>in</strong>g n entries, <strong>and</strong> let h be the<br />

height of T. We justify the proposition by establish<strong>in</strong>g the follow<strong>in</strong>g bounds on h:<br />

By the size <strong>and</strong> depth properties, the number n ′′ of external nodes of T is at least<br />

2a h− 1 <strong>and</strong> at most b h . By Proposition 10.7, n ′′ = n + 1. Thus<br />

2a h − 1 ≤ n + 1 ≤ b h .<br />

Tak<strong>in</strong>g the logarithm <strong>in</strong> base 2 of each term, we get<br />

(h − 1)loga + 1 ≤ log(n + 1) ≤ hlogb.<br />

.<br />

Search <strong>and</strong> Update Operations<br />

We recall that <strong>in</strong> a multi-way search tree T, each node v of T holds a secondary<br />

structure D(v), which is itself a dictionary (Section 10.4.1). If T is an (a, b) tree,<br />

then D(v) stores at most b entries. Let f(b) denote the time for perform<strong>in</strong>g a search<br />

<strong>in</strong> a D(v) dictionary. The search algorithm <strong>in</strong> an (a, b) tree is exactly like the one<br />

for multi-way search trees given <strong>in</strong> Section 10.4.1. Hence, search<strong>in</strong>g <strong>in</strong> an (a, b)<br />

tree T with n entries takes O(f(b)/logalogn) time. Note that if b is a constant (<strong>and</strong><br />

thus a is also), then the search time is O(logn).<br />

The ma<strong>in</strong> application of (a, b) trees is for dictionaries stored <strong>in</strong> external memory.<br />

Namely, to m<strong>in</strong>imize disk accesses, we select the parameters a <strong>and</strong> b so that each<br />

tree node occupies a s<strong>in</strong>gle disk block (so that f(b) = 1 if we wish to simply count<br />

block transfers). Provid<strong>in</strong>g the right a <strong>and</strong> b values <strong>in</strong> this context gives rise to a<br />

data structure known as the B-tree, which we will describe shortly. Before we<br />

902

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

Saved successfully!

Ooh no, something went wrong!