Menu

[Solved]Given Methods Method Math1 Public Int Math1 Int N N Q37247058

Given these methods:

METHOD math1:

public int math1( int n ) {

if (n <= 1) {

return 1;

} // if

else {

return ( n * 2 ) + math1( n-1 );

} // else

} // math1

METHOD math2:

public int math2( int n ) {

if (n <= 1) {

return 1;

} // if

else {

return n + math1( n ) * math2( n/2 );

} // else

} // math2

(a) Set up a recurrence relation for the running time of themethod math1 as a function of n. Solve your recurrence relation tospecify theta bound of math1.

(b) Now set up a recurrence relation for the running time of themethod math 2 as a function of n. Solve your recurrence relation tospecify the Big-Oh bound of math 2.

HINT: When doing this, the call to math 1 can be replaced by theequation that you found when solving the recurrence relation formath 1 in part a).

Expert Answer


Answer to Given these methods: METHOD math1: public int math1( int n ) { if (n … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *