Professional Documents
Culture Documents
2. Why do we use asymptotic notations in the study of algorithms? Briefly describe the
commonly used asymptotic notations mathematically and illustrate them graphically.
3. Let f(n) and g(n) be asymptotically positive functions. Prove or disprove following.
(1) f(n) + g(n) = Θ(min(f(n), g(n))).
(2) f(n) + g(n) = O(max(f(n), g(n))).
4. Find big oh(O), big theta(Θ) and big omega ( Ω) notation for following;
(1) f(n) =6993, (2) f(n) =6n2+135 (3) f(n) = 83n3 +84 n
9. Give an analysis of the running time (Big-Oh notation) for each of the following program
fragments.
(a) (b)
sum = 0; sum = 0;
for(i=0;i<sqrt(n)/2;i++) for(i=1;i<2*n;i++)
sum++; for(j=1;j<i*i;j++)
for(j=0 ;j<sqrt(n)/4;j++) for(k=1;k<j;k++)
sum++; if (j % i)
for(k=0;k<8+j;k++) sum++;
sum++;
10. Analyze the following algorithms and specify the best-case, worst-case and average-case
complexity by assuming an input array of size N:
(1) Bubble sort (2) Selection Sort (3) Insertion Sort (4) Heap Sort
(5) Shell Sort (6) Counting Sort