Question

I'm having some trouble with an asymptotic analysis question : My Question is to calculate maximum value if 'a' as stated in my question:

An Algorith A has running time T(n)= 7T(n/2) + n^2
and Algorith B has running time T' = aT'(n/4) + n^2.
What will be the maximum integer value of 'a' such that algorith B runs 
asymptotically faster than A.

How should i find the value of 'a' should i use only algorith concept in this or is their any other way to find out or any solutions.

Was it helpful?

Solution

This is a great spot to use the Master Theorem.

In the first recurrence, T(n) = 7T(n/2) + n2, the Master Theorem, says that

  • a = 7
  • b = 2
  • d = 2

Since logb a = log2 7 is greater than d = 2, the recurrence solves to T(n) = Θ(nlog27).

Now, let's look at T'(n). Here, we have a unknown, b = 4, and d = 2. If we have the following conditions holding true:

  • log4a > 2, and
  • log4a < log2 7

Then the Master Theorem says that T'(n) = Θ(nlog4a) = o(nlog27) and we're done. So we need to solve for a.

Doing this gives

log4a < log2 7

log2a / log2 4 < log2 7 (using the change of base formula for logs)

log2 a / 2 < log2 7

log2 a < 2 log 2 7

log2 a < log2 72 (using the power rule for logs)

log2 a < log2 49

a < 49

Therefore, the largest integral a you can pick is 48.

Hope this helps!

OTHER TIPS

Solve the equations to get a non-recursive runtime formula

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top