Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions