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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started