Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Determine the big-oh time complexity for each of the following codes: (1) assert (n > 1); m = x[0]; for (i = 1; i <

Determine the big-oh time complexity for each of the following codes:
(1) assert (n > 1);
m = x[0];
for (i = 1; i < n; i++)
if (x[i] < m) m = x[i];
(2) for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
x[i][j] = 0.0;
for ( k = 0; k < n; k++) x[i][j] += y[i][k] * z[k][j];
}
}
(3) for (i = 1; i < n; i++) {
a = x[i];
j = i 1;
while (j >= 0 && a < x[j]) {
x[j+1] = x[j];
j = j 1;
}
x[j+1] = a;
}
(4) float x (float a, int n)
{ if ( n == 0) return 1.0;
else if (even (n))
return x(a * a, n /2);
else
return (a * a, n/2) * a;
}
(5) for (i = 5; i <= 2 * n; i++)
cout << 2 * n + i 1; << enld;
(6) i = 0;
while ( i < n) {
f(); // call a function f where the complexity of function f is n^2
i = i *2
}

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

Students also viewed these Databases questions

Question

Question May I set up a Keogh plan in addition to an IRA?

Answered: 1 week ago