0% found this document useful (0 votes)
40 views

ADA Assignment On Analysis

The document contains 23 questions related to analysis of algorithms. The questions cover topics like asymptotic notation, time complexity analysis of algorithms, and sorting algorithms including selection sort, bubble sort, insertion sort, shell sort, counting sort, radix sort, bucket sort, and heap sort. Examples are provided to illustrate operations of various sorting algorithms on sample arrays.

Uploaded by

Kevin Jiju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

ADA Assignment On Analysis

The document contains 23 questions related to analysis of algorithms. The questions cover topics like asymptotic notation, time complexity analysis of algorithms, and sorting algorithms including selection sort, bubble sort, insertion sort, shell sort, counting sort, radix sort, bucket sort, and heap sort. Examples are provided to illustrate operations of various sorting algorithms on sample arrays.

Uploaded by

Kevin Jiju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Government Engineering College, Rajkot

Computer Engineering Department


Subject: Analysis and Design of Algorithms
Subject Code: 3150703
B.E. Semester: 5th
Assignment – Analysis
1. Arrange following rate of growth in increasing order.
2n, nlgn, n2, 1, n, lgn, n!, n3, nn, n!, √
2. Arrange following growth rates in increasing order.
O(n1/4), O(n1.5), O(n3 lg n), O(n1.02), Ω(n6), Ω(n!), O(√n), O(n6/2), Ω(2n)
3. What is the smallest value of n such that an algorithm whose running time is 100n2 runs
faster than an algorithm whose running time is 2n on the same machine?
4. Consider an array A of n elements. Each value of array A is filled from set S
={0,1,2,3,…..,n-2,n-1,n}. There are no duplicate values filled in array A. Design an
algorithm that finds which element from set S is missing in array A such that worst case
time complexity is O(n).
5. Find Big-Oh Notation the f(n)= 3n2+5n+10
6. Find Omega (Ω) notation of function f(n)=2n2 + 6 n*lg n + 6n
7. Find upper bound of function f(n)= lg(n2) + n2 lg n.
8. Prove that T(n) = n3 + 20n is Ω(n2)
9. Prove that T(n) = n3 + 20n + 1 is not O(n2)
10. Is 2n+1 = Ο(2n) ? Explain.
11. Is 22n = Ο(2n) ? Explain.
12. Let f(n) and g(n) be asymptotically positive functions. Prove following.
f(n) + g(n) = Θ(max(f(n), g(n))).
13. Prove that (n + a)b = Ө( nb) , b>0
14. Prove that (lgn)lgn = Ω(n3/2)
15. Prove that lg(n!) = Ө(nlgn)
16. If P(n) = a0+ a1 n + a2 n2 + . . . . . . + amnm then prove that P(n) = O(nm). Here a0, a1, a2
…..am are constants and am>0.
17. Find out time complexity for the following pseudo codes using O-notation.

Example 1: Example 2:
Algorithm algo1 (n) Algorithm algo2 (n)
{ {
c=0;
c=0; for( i = 1; i <= n; i++) {
for(i = 0; i < n; i++) { for( i = 1; i <= 5; i++) {
for(j = n ; j > 0 ; j--) { c = c +1
if( i < j )
c = c + 1; }
} }
} }
}
Example 3 Example 7
Algorithm algo3 (n) Algorithm algo7 (n)
{ {
c=0; c=0;
for( i=n ; i >1; i = i/2) { for( i=1; i<=n*n*n, i++) {
c = c+1 c = c+1;
} }
}
}
Example 4 Example 8
Algorithm algo4 (n) Algorithm algo8 (n, m)
{ {
i = 1; c=0;
s = 1; for( i=1; i<=n ; i++) {
while ( s <=n) { for (j=1;j<=m;j++){
i++; c = c+1;
s = s + i; }
} }
}
Example 5 }
Algorithm algo5 (n) Example 9
{ Algorithm algo9 (n)
c=0; {
for (i =0; i<=3*n; i++) { i=1;j=0;
c = c+1; while (i<n){
} j=n;
} while (j>0) {
Example 6 j = j/2;
Algorithm algo6 (m , n) }
{ i = i *2;
c=0; }
for( i=1; i<=m, i++) { }
c = c+1; Example 10
} Algorithm algo10 (n)
for( i=1; i<=n, i++) { {
c = c+1; c = 0;
} for (i=n;i>=0;i=i/2) {
} for( j=0;j<i;j++ ){
c = c+1;
}
}
}
18. Sort following using Selection Sort, Bubble Sort and Insertion Sort. Show your steps.
(i) A={98,54,86,9,92,43,71}
(ii) A={E,X,A,M,P,L,E}
19. Show operation of Shell Sort on array A = {81, 23, 21, 50, 83, 33, 61, 20}
20. Illustrate the operation of Counting Sort on array A = {6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2}
21. Illustrate the operation of Radix Sort on array A = { 329, 457, 657, 839, 436, 720, 355}
22. Show operation of Bucket Sort using figure on array A = {.97, .31, .61, .46, .93, .12, .98,
.35, .17, .24}
23. Illustrate the operation of Heap Sort on array A = {5, 13, 2, 25, 7, 17, 20, 8, 4}

You might also like