SUBJECT NAME: DAA
YEAR/SEM: III/I
UNIT 1
1. A) What are the features of an efficient algorithm? Explain with an example. [5M]
B) Write an algorithm to find the maximum element in an array of n elements. [5M]
2. A) Write the algorithm to find a factorial of a given number. Derive its efficiency [5M]
B) Give the algorithm for matrix additions and determine the time complexity of this
algorithm by frequency-count method. [5M]
3. A) Explain the process of designing an algorithm. Give characteristics of an algorithm. [5M]
B) What is the time complexity of following function fun ( )? Explain. [5M]
int fun (int n)
{
for (inti = 1; i<=n; i++)
for (int j = 1; j < n; j +=i)
Sum = Sum + i*j;
return (Sum);
}
4. A) Discuss the Pseudo code conventions for expressing algorithms. [5M]
b) Write an algorithm for Bubble sort and analyze the algorithm for its time complexity.
[5M]
5. A) How to measure the performance of an algorithm? Give some parameters. [5M]
b) Write Randomized algorithm of Quick sort. [5M]
UNIT 2
1. A) Write Divide-And-Conquer recursive Merge sort algorithm and derive the time complexity
of this algorithm. [5M]
b) Write an algorithm for prim’s method and find the minimum cost spanning tree for the
following graph. [5M]
2. A) Derive the Best, Worst and Average time complexities of Quick sorting technique. Show
the result of running Quick sorting technique on the sequence 38, 27, 43, 3, 9, 65, 12, 82, 10,
56 [5M]
b) Find shortest path using dijkstra’s algorithm for following graph [5M]
3. A) Find the minimum and maximum values for the list of elements 23, 45, 32, 78, 54, 12, 39,
86, 77, 21 using divide and conquer method. [5M]
b) Construct Minimum cost spanning tree using Kruskal’s algorithm. [5M]
4. Apply the greedy method to solve Knapsack problem for given instance Where n=3, m=20,
(p1,p2,p3)=(25,24,15), and weight (w1,w2,w3)=(18,15,10). [10M]
5. A) Perform binary search on list of elements to find the key element using divide and
conquer, and also estimate the time complexity. [5M]
B) Construct Minimum cost spanning tree using Prim’s algorithm. [5M]
UNIT 3
1. Calculate shortest distances using All pairs shortest path algorithm [10M]
2. Solve the following instance of 0/1 KNAPSACK problem using Dynamic programming. n =
3, (W1,W2,W3) = (2,3,4), (P1,P2,P3) = (1,2,5), and m = 6. [10M]
3. Write a function to compute lengths of shortest paths between all pairs of nodes for the
given adjacency matrix [10M]