online advertising
Processing math: 100%

Saturday, October 24, 2015

Algorithms: Design and Analysis, Part 1 - Problem Set 2 - Question 4

Problem:

Now assume that you achieve the approximately balanced splits above in every recursive call --- that is, assume that whenever a recursive call is given an array of length k, then each of its two recursive calls is passed a subarray with length between αk and (1α)k (where 0<α<.5). How many recursive calls can occur before you hit the base case, as a function of α and the length n of the original input? Equivalently, which levels of the recursion tree can contain leaves? Express your answer as a range of possible numbers d, from the minimum to the maximum number of recursive calls that might be needed. [The minimum occurs when you always recurse on the smaller side; the maximum when you always recurse on the bigger side.]

Solution:

The smallest d occurs when we always recurse on the smaller side, therefore αdn=1, or in other words,

log(αdn)=0dlog(α)+log(n)=0d=lognlogα

Similarly, the largest d occurs when we always recurse on the larger side, therefore (1α)dn=1, we get a similar upper bound.

The answer is now lognlogαdlognlog(1α)

1 comment: