Mastery of Runtime Needed!

Suppose we have a recursive function, T ( n ) T(n) ,

T ( n ) = 2 T ( n 2 ) + O ( n ) T(n)=2T\left(\frac{n}{2}\right) + O(n)

What is the best asymptotic bound for T ( n ) T(n) ?

Bonus: Can you describe a well known algorithm that has a recurrence that looks like this?

O ( 1 ) O(1) O ( n log n ) O(n \log n) O ( n ) O(n) O ( n 2 ) O(n^2)

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Spencer Whitehead
Feb 25, 2016

Since we have the recurrence, all that remains to do is solve it using the master method .

We can see from the given function that a = 2 , b = 2 , c = 1 , f ( n ) O ( n ) a=2,b=2,c=1,f(n)\in O(n) . This falls under case 2, as we have log b a = c \log_b a = c . Since we can rewrite O ( n ) O(n) as O ( n 1 log 0 n ) O(n^1 \log^0 n) , it follows that the upper bound is O ( n 1 log 0 + 1 n ) = O ( n log n ) O(n^1 \log^{0+1} n)=O(n \log n) .

An algorithm with this recurrence that many may be familiar with is the merge sort, though others exist! See if you can come up with another similar algorithm.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...