Question: 1. Runtime analysis. Given the following piece of code: public static void mystery( int n) { if(n==1) { System.out. println(Something); } else { } }

1. Runtime analysis. Given the following piece of code:

public static void mystery( int n)

{ if(n==1) {

System.out. println(Something);

} else {

} }

System.out. println(Something);

mystery(n/2);

Let T(n) be the running time of mystery in terms of its argument n.

a- write the T (n) formula explain briefly.

b- What is the runtime of this function based on the T (n) formula you derived?

c- Exactly how many times will Something be printed for n = 7?

d-This part is unrelated to (a-c) above. A given algorithm runs as O(2n) where n is the input size. If the algorithm takes 10 seconds to run on an input of size 5, what is the input size that makes the algorithm run for approximately 40 seconds? Explain.

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!