Question

Caps Lock A S D レ For each of the bełow code snippets, identify the bounding f tion (the big O) of the number of times the indicated line is c 6. Growth Analysis (2 points) your answer briefly) int i=1; while (i <n) { printf (Insert difficult work here! si+i THIS LINE/ for (i =0; i < n; i++) { for (j = 0; j < n; j++) { for (k = 0; k < n; k++) { if(i-j &jk) arr [i] [j] [k]=1; /* THIS LINE/

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int i = 1;
while (i < n) {

    printf("Insert difficult work here!"); (This Line)
    i = i +1;
}

The complexity is of O(n). The loop is running for n times as i starting with 1 and going up to n.


for(i=0; i<n; i++) {
   for(j=0; j<n; i++) {
       for(k=0; k<n; i++) {
           if (i==j && j==k)
                arr[i][j][k] = 1; (This Line)
          
       }
   }
}

This is again O(n) . For i = 1 the statement will be executed only once (i.e j = 1 && k = 1). So it means that for each value of i, the statement will be executed once and i is going from 1 to n so it is of order(n)

Add a comment
Know the answer?
Add Answer to:
For each of the below code snippets, identify the bounding function (the big O) of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT