Answered You can hire a professional tutor to get the answer.

QUESTION

I'm having trouble with understanding the concept of time complexity and big-o estimate.

Urgent please help. I'm having trouble with understanding the concept of time complexity and big-o estimate.. For the following parts, try to get the best Big-O estimate and briefly justify your answers. programming c language.

Part a) (nested loop)

int i, j;

int n = 100;

for (i = 1; i <= n; i++) {

for (j = 3*i; j <= n; j++) {

printf("programming is funn");

}

}

(Is this one O(n^2)?

Part b)(nested loop)

int i, j;

int n = 1000000;

for (i = 1; i <= n; i++) {

for (j = 1; j <= 10000; j++) {

printf("%d %dn", i, j); 

}

}

(is this one O(N)?

Part c)(nested loop)

int i = 0;

int n = 10;

int j;

while (i < n) {

i++;

j = i;

while (i < n) {

printf("hello %dn", i);

i++;

}

i = j; 

}

Part d)(nested loop)

int i = 0;

int n = 10;

int j;

while (i < n) {

i++;

j = i;

while (i < n) {

printf("hello %dn", i);

i++;

break;

}

i = j; 

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question