06.03.2017 Views

Mathematics for Computer Science

e9ck2Ar

e9ck2Ar

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

“mcs” — 2017/3/3 — 11:21 — page 957 — #965<br />

22.5. A Feel <strong>for</strong> Recurrences 957<br />

Divide-and-conquer recurrences are also sensitive to the number of subproblems.<br />

For example, <strong>for</strong> this generalization of the Merge Sort recurrence:<br />

T 1 D 0<br />

T n D aT n=2 C n 1:<br />

the Akra-Bazzi <strong>for</strong>mula gives:<br />

8<br />

ˆ< ‚.n/ <strong>for</strong> a < 2<br />

T n D ‚.n log n/ <strong>for</strong> a D 2<br />

ˆ:<br />

‚.n log a / <strong>for</strong> a > 2:<br />

So the solution takes on three completely different <strong>for</strong>ms as a goes from 1.99<br />

to 2.01!<br />

How do boundary conditions affect the solution to a recurrence? We’ve seen<br />

that they are almost irrelevant <strong>for</strong> divide-and-conquer recurrences. For linear recurrences,<br />

the solution is usually dominated by an exponential whose base is determined<br />

by the number and size of subproblems. Boundary conditions matter<br />

greatly only when they give the dominant term a zero coefficient, which changes<br />

the asymptotic solution.<br />

So now we have a rule of thumb! The per<strong>for</strong>mance of a recursive procedure is<br />

usually dictated by the size and number of subproblems, rather than the amount<br />

of work per recursive call or time spent at the base of the recursion. In particular,<br />

if subproblems are smaller than the original by an additive factor, the solution is<br />

most often exponential. But if the subproblems are only a fraction the size of the<br />

original, then the solution is typically bounded by a polynomial.<br />

Problems <strong>for</strong> Section 22.4<br />

Homework Problems<br />

Problem 22.1.<br />

The running time of an algorithm A is described by the recurrence T .n/ D 7T .n=2/C<br />

n 2 . A competing algorithm A 0 has a running time of T 0 .n/ D aT 0 .n=4/ C n 2 . For<br />

what values of a is A 0 asymptotically faster than A?<br />

Problem 22.2.<br />

Use the Akra-Bazzi <strong>for</strong>mula to find ‚./ asymptotic bounds <strong>for</strong> the following divideand-conquer<br />

recurrences. For each recurrence, T .1/ D 1 and T .n/ D ‚.1/ <strong>for</strong> all

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

Saved successfully!

Ooh no, something went wrong!