(17*) (4x3 marks + 2x4 marks) 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...


(17*) (4x3 marks + 2x4 marks)<br>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. sqrt is the function that returns the square root of a given number. )<br>Program<br>Running time (Big-Oh notation)<br>sum<br>0;<br>for (i=0;i<sqrt(n)/2;i++)<br>sum++;<br>A for (j=0 ;j<sqrt(n)/4;j++)<br>sum++;<br>for (k=0;k<8+j;k++)<br>sum++;<br>sum =<br>0;<br>for (i=0;i<sqrt(n)/2;i++)<br>for (j=i;8+i;j++)<br>В<br>for(k=j;k<8+j;k++)<br>sum++;<br>0;<br>for (i=1;i<2*n;i++)<br>sum<br>%3D<br>for (j=1;j<i*i;j++)<br>for (k=1;k<j;k++)<br>if (j%i==1)<br>C<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>CS Scanned with CaScanner<br>Sumti;<br>

Extracted text: (17*) (4x3 marks + 2x4 marks) 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. sqrt is 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++;="" 0;="" for="" (i=""><2*n;i++) sum %3d for (j=1;j sum="" %3d="" 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