Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let T ( n ) denote the number of times that the recursive function DoSomething ( n ) prints ` ` banana . int

Let T(n) denote the number of times that the recursive function DoSomething(n) prints ``banana."
int DoSomething(int n)
{
for (int i=1; i <= n; i=i+1){ print "banana";}
if (n <=2) return 1;
else {
x =0;
for (int j=1; j<= n; j++){ x = x+DoSomething(n/2);}
return x*x;
}
}
Give a recurrence relationship for T(n)? For simplicity you may assume that n is a power of 2.
a. T(n)= n*T(n/2)+ n for n >2 and T(n)= n for n<=2.
b. T(n)= n*T(n/2)+ log n for n >2 and T(n)=1 for n<=2.
c.T(n)= n*T(n/2)+ n for n >2 and T(n)=0 for n<=2.
d. T(n)=2*T(n/2)+ n for n >2 and T(n)=0 for n<=2.
e. T(n)= T(n/2)+ n for n >2 and T(n)=0 for n<=2.
f. T(n)= T(n/2)+ log n for n >2 and T(n)=0 for n<=2.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

What do you think of the MBO program developed by Drucker?

Answered: 1 week ago