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α≤d≤−lognlog(1−α)
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α≤d≤−lognlog(1−α)
how did you get α^d * n=1 ?
ReplyDelete