Question: Hi, I need assitance with my assignment, understanding Big-Oh analysis , please give me the step by step breakdown for these 2 questions. // Fragment

Hi, I need assitance with my assignment, understanding Big-Oh analysis, please give me the step by step breakdown for these 2 questions.

// Fragment 7

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

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

for( int k = 0; k < j; k++ )

sum++;

// Fragment 8

for ( int i = 1; i < n*n; i *= 3 )

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

for ( int k = 1; k < i; k += 2 )

sum++; [for loop nest ends]

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

if ( i % 4 == 0 )

for ( int j = 1; j < i; j++ )

sum++;

Thank you.

This format doesnt allow me to show you that the for loops are nested, so for fragment 7 they are and for fragment 8 i specified when the nested loop ends. thank you.

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!