06.03.2017 Views

Mathematics for Computer Science

e9ck2Ar

e9ck2Ar

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.

“mcs” — 2017/3/3 — 11:21 — page 951 — #959<br />

22.4. Divide-and-Conquer Recurrences 951<br />

In particular, T .n/ is not a linear combination of a fixed number of immediately<br />

preceding terms; rather, T .n/ is a function of T .n=2/, a term halfway back in the<br />

sequence.<br />

Merge Sort is an example of a divide-and-conquer algorithm: it divides the input,<br />

“conquers” the pieces, and combines the results. Analysis of such algorithms<br />

commonly leads to divide-and-conquer recurrences, which have this <strong>for</strong>m:<br />

T .n/ D<br />

kX<br />

a i T .b i n/ C g.n/<br />

iD1<br />

Here a 1 ; : : : a k are positive constants, b 1 ; : : : ; b k are constants between 0 and 1,<br />

and g.n/ is a nonnegative function. For example, setting a 1 D 2, b 1 D 1=2 and<br />

g.n/ D n 1 gives the Merge Sort recurrence.<br />

22.4.1 The Akra-Bazzi Formula<br />

The solution to virtually all divide and conquer solutions is given by the amazing<br />

Akra-Bazzi <strong>for</strong>mula. Quite simply, the asymptotic solution to the general divideand-conquer<br />

recurrence<br />

is<br />

where p satisfies<br />

T .n/ D<br />

kX<br />

a i T .b i n/ C g.n/<br />

iD1<br />

Z n<br />

<br />

T .n/ D ‚<br />

n p g.u/<br />

1 C<br />

1 u pC1 du<br />

(22.2)<br />

kX<br />

a i b p i<br />

D 1: (22.3)<br />

iD1<br />

A rarely-troublesome requirement is that the function g.n/ must not grow or<br />

oscillate too quickly. Specifically, jg 0 .n/j must be bounded by some polynomial.<br />

So, <strong>for</strong> example, the Akra-Bazzi <strong>for</strong>mula is valid when g.n/ D x 2 log n, but not<br />

when g.n/ D 2 n .<br />

Let’s solve the Merge Sort recurrence again, using the Akra-Bazzi <strong>for</strong>mula instead<br />

of plug-and-chug. First, we find the value p that satisfies<br />

2 .1=2/ p D 1:

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

Saved successfully!

Ooh no, something went wrong!