Question: 0. Does Big O indicate how many times your program will loop or how many instructions will be executed in a loop? Explain please. I

0. Does Big O indicate how many times your program will loop or how many instructions will be executed in a loop? Explain please. I am confused.

1. Given the following formulas for algorithm efficiency, express each formula in Big O notation:

a. n3 + 5 n2

b. 3n2 + 5n* 5n

c. 250n2 * 100n

d. the number of times a number n can be divided by 5 before dropping below 5.

What is the Big O for each of the following code?

2. for ( i = 0; i < n; i ++ )

{ j += i; }

3. for ( k = 2*n; k > 0; k-- )

{ j = k * 2;

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

tot = tot + j * k;

}

4. i = n;

while ( i > 0 )

{ acc = acc + i * n * n;

i = i / 2;

}

5. k = n * n;

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

while ( k > 0 )

{ acc = acc + i * k;

k = k / 2;

}

6. for ( i = 0; i < n*n; i ++ )

{ k = 0;

while ( k < n*n )

{ acc = acc + k * i;

k = k * 2;

}

}

7. k = n * n;

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

{ t = t + i * i;

s = t / 2;

}

while ( k > 0 )

{ acc = acc + i * 5;

k = k / 2;

}

8. int *p;

p = head; ; beginning of link list

while ( p != null && ( p->value != target ) p = p -> linky;

9. Why is the Big O of the Bubble sort and the Selection Sort consider to be n2?

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!