Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

Students also viewed these Databases questions