Question: ( 3 ) [ 2 0 pts . ] Given this method: METHOD T 1 : public int T 1 ( int n ) {

(3)[20 pts.] Given this method:
METHOD T1:
public int T1( int n ){
if (n <1){
return 0;
}// if
else {
return (n + T1(n-1));
}// else
}// T1
(a) Set up a recurrence relation for the running time of the method T1 as a function of n. Solve your recurrence relation to specify theta bound of math1.
METHOD T2:
public int T2(int n){
if (n <1){
return 0;
}// if
else {
return T1(n)+ T2(n/2) n/2;
}// else
}// T2
(b) Now set up a recurrence relation for the running time of the method T2 as a function of n. Solve your recurrence relation to specify theta bound of math 2.
HINT: When doing this, the call to T1 can be replaced by the equation that you found when solving the recurrence relation for T1 in part a).(3)[20 pts.] Given this method:
METHOD T1:
public int T1( int n ){
if (n <1){
return 0;
}// if
else {
return (n + T1(n-1));
}// else
}// T1
(a) Set up a recurrence relation for the running time of the method T1 as a function of n. Solve your recurrence relation to specify theta bound of math1.
METHOD T2:
public int T2(int n){
if (n <1){
return 0;
}// if
else {
return T1(n)+ T2(n/2) n/2;
}// else
}// T2
(b) Now set up a recurrence relation for the running time of the method T2 as a function of n. Solve your recurrence relation to specify theta bound of math 2.
HINT: When doing this, the call to T1 can be replaced by the equation that you found when solving the recurrence relation for T1 in part a).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!