Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For ( a ) and ( b ) , select the recurrence representing the recursive runtimes of each method in terms of n . Assume

For (a) and (b), select the recurrence representing the recursive runtimes of each method in terms of n. Assume that any +,-,*,/,% operations and
System.out.println()calls take constant runtime. Don't worry about finding the exact constants for the non-recursive term. For example, if the running time is
T(n)=4T(n/3)+25n, you need to get the 4 and the 3 right but you don't have to worry about getting the 25 right.
Question 1.1 From Code to Reccurence
Q1.1 From Code to Reccurence
1 Point
Grading comment:
Write the recurrence of the recursive case (not the base case) for
mystery(n,1), where the initial value of the parameter
step =1
/*
* A mystery method
*/
public void mystery(int n, int step){
if (n <= step){
return;
}
for (int i =0; i < n; i += step){
int a = i + n /2;
System.out.print(a * a +"");
}
System.out.println();
mystery(n, step *2);
mystery(n, step *2);
}
The following multiple-choice options contain math elements, so you may need to read them in your screen reader's reading or browse mode instead of forms or focus mode.
Choice 1 of 4:
T(n)=3T(n/2)+n
Choice 2 of 4:
T(n)=2T(n/3)+25
Choice 3 of 4:
T(n)=2T(n/2)+n
Choice 4 of 4:
T(n)=3T(n/3)+25

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

=+8. For the decision tree of Exercise 4,

Answered: 1 week ago