Question

b) Base 7. Master Theorem (3 points) Consider the following recursive function for n >0 case: a| c) Recursive case: an Algorithm 1 int recFunc(int n) //Base Case if n <= 2 then return n; end if / /Recursive Case: while i< n do print(Hello!) end while int a 2*recFunc(n/2); return a; Find the runtime of the above recursive function using the master theorem

please also explain how the answer came about if possible

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Let T(n) be the time taken for input n

Base Case is T(1) = 1

One while loop which runs for n time and One recursive call of 2*RecursiveCall(n/2)

T(n) = 2*T(n/2) + n


We Can solve the using Master's theorem :-

a = 2 , b = 2, f(n) = n

g(n) = nlogb a = nlog 22 = n

We can see f(n) = g(n) , Hence T(n) = O(nlogb a log n) =>

T(n) = O(nlog n)

Add a comment
Know the answer?
Add Answer to:
please also explain how the answer came about if possible b) Base 7. Master Theorem (3...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT