Question: show the runtime analysis in Big-O notation int silly(int n, int m) { if (m < 2) return m; if (n < 1) return n;

show the runtime analysis in Big-O notation

int silly(int n, int m) {

if (m < 2) return m;

if (n < 1) return n;

else if (n < 10)

return silly(n/m, m);

else

return silly(n - 1, m);

} __________________

void silly(int n, int x, int y) {

if (x < y) {

for (int i = 0; i < n; ++i)

for (int j = 0; j < n * i; ++j)

System.out.println(y = + y);

} else {

System.out.println(x = + x);

}

} __________________

void silly(int n) {

j = 0;

while (j < n) {

for (int i = 0; i < n; ++i) {

System.out.println(j = + j);

}

j = j + 5;

}

} __________________

void silly(int n) {

for (int i = 0; i < n * n; ++i) {

for (int j = 0; j < n; ++j) {

for (int k = 0; k < i; ++k)

System.out.println(k = + k);

for (int m = 0; m < 100; ++m)

System.out.println(m = + m);

}

}

} __________________

void happy(int n) {

for (int i = n*n; i > 0; i--) {

for (int k = 0; k < n; ++k)

System.out.println(k = + k);

for (int j = 0; j < i; ++j)

System.out.println(j = + j);

for (int m = 0; m < 5000; ++m)

System.out.println(m = + m);

}

} __________________

Consider the following function:

int mystery(int n) {

int answer;

if (n > 0) {

answer =(mystery(n-2)+3*mystery(n/2) + 5);

return answer;

}

else

return 1;

}

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!