Question: PLEASE HELP ME 2) 20 points. Big-O Analysis. a) Use the definition of Big-O, prove that 6n 3 + 12n 2 + 2n + 1
PLEASE HELP ME
2) 20 points. Big-O Analysis.
a) Use the definition of Big-O, prove that 6n3 + 12n2 + 2n + 1 has an upper bound of O(n3)?
b) Give meaningful and Big-O bounds for the following two functions and justify your answers. The algorithms dont compute anything worthwhile so just focus on the runtime.
int algo1(int n)
{
sum = 0;
for( int i = 0; i < n; ++i )
for( int j = 0; j < i * i; ++j )
for( int k = 0; k < j; ++k )
++sum;
return sum;
}
int algo2(int n)
{
sum = 0;
for( int i = 1; i < n; ++i )
for( int j = 1; j < i * i; ++j )
if( j % i == 0 )
for( int k = 0; k < j; ++k )
++sum;
return sum;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
