Question & Answer: For each of the below code snippets, identify the bounding function (the big O) of the number of times the indicated line is r…..

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/

For each of the below code snippets, identify the bounding function (the big O) of the number of times the indicated line is run (justify your answer briefly): int i = 1: while (i

Expert Answer

 

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: For each of the below code snippets, identify the bounding function (the big O) of the number of times the indicated line is r…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

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)

Still stressed from student homework?
Get quality assistance from academic writers!