1. Give an analysis of the running time (Big-Oh notation) for each of the following 4 program fragments. Note: the running time corresponds here to the number of times the operation sum++ is executed....


1. Give an analysis of the running time (Big-Oh notation) for each of the following 4 program<br>fragments. Note: the running time corresponds here to the number of times the operation sum++ is<br>executed. sqrtis the function that returns the square root of a given number. }<br>Program<br>Running time (Big-Oh notation)<br>sum = 0;<br>for (i=0;i<sqrt(n)/2;i++)<br>sum++;<br>A<br>for (j=0 ;j<sqrt(n)/4;j++)<br>sum++;<br>for (k=0;k<8+j;k++)<br>sum++;<br>sum = 0;<br>for (i=0;i<sqrt (n)/2;i++)<br>for (j=i;8+i;j++)<br>for (k=j;k<8+j;k++)<br>sum++;<br>sum = 0;<br>for (i=1;i<2*n;i++)<br>for (j=1;j<i*i;j++)<br>for (k=1; k<j; k++)<br>if (j%i==1)<br>sum++;<br>sum = 0;<br>for (i=1;i<2*n;i++)<br>for (j=1;j<i*i;j++)<br>for (k=1;k<j;k++)<br>if (j%i)<br>D<br>sum++;<br>

Extracted text: 1. Give an analysis of the running time (Big-Oh notation) for each of the following 4 program fragments. Note: the running time corresponds here to the number of times the operation sum++ is executed. sqrtis the function that returns the square root of a given number. } Program Running time (Big-Oh notation) sum = 0; for (i=0;i<8+j;k++) sum++;="" sum="0;" for="" (i=""><8+j;k++) sum++;="" sum="0;" for="" (i=""><2*n;i++) for (j=1;j for="" (j="">
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here