Question: Big-Oh and Run Time Analysis: Describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n.
Big-Oh and Run Time Analysis: Describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n.
a) 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);
} __________________
b) 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);
}
} __________________
c) void silly(int n) {
j = 0;
while (j < n) {
for (int i = 0; i < n; ++i) {
System.out.println(j = + j);
}
j = j + 5;
}
} __________________
d) 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);
}
}
} __________________
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
