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 959 — #967<br />

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

The final, merged list is the output. What’s great is that because multiple copies<br />

of each number are maintained, even if the sorter occasionally <strong>for</strong>gets about a number,<br />

OverSort can still output a complete, sorted list.<br />

(a) Let T .n/ be the maximum number of comparisons that OverSort could use<br />

to sort a list of n distinct numbers, assuming the sorter never <strong>for</strong>gets a number and<br />

n is a power of 3. What is T .3/? Write a recurrence relation <strong>for</strong> T .n/. (Hint:<br />

Merging a list of j distinct numbers and a list of k distinct numbers, and throwing<br />

out duplicates of numbers that appear in both lists, requires j Ck d comparisons,<br />

when d > 0 is the number of duplicates.)<br />

(b) Now we’re going to apply the Akra-Bazzi Theorem to find a ‚ bound on<br />

T .n/. Begin by identifying the following constants and functions in the Akra-Bazzi<br />

recurrence (22.4):<br />

The constant k.<br />

The constants a i .<br />

The constants b i .<br />

The functions h i .<br />

The function g.<br />

The constant p. You can leave p in terms of logarithms, but you’ll need a<br />

rough estimate of its value later on.<br />

(c) Does the condition jg 0 .x/j D O.x c / <strong>for</strong> some c 2 N hold?<br />

(d) Does the condition jh i .x/j D O.x= log 2 x/ hold?<br />

(e) Determine a ‚ bound on T .n/ by integration.<br />

Exam Problems<br />

Problem 22.4.<br />

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

For each recurrence T .0/ D 1 and n 2 N.<br />

(a) T .n/ D 2T .bn=4c/ C T .bn=3c/ C n<br />

(b) T .n/ D 4T n=2 C p n˘ C n 2<br />

(c) A society of devil-worshipers meets every week in a catacomb to initiate new<br />

members. Members who have been in the society <strong>for</strong> two or more weeks initiate<br />

four new members each and members who have been in the society <strong>for</strong> only one

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

Saved successfully!

Ooh no, something went wrong!