Dec 2019 CS302 - Design and Analysis of Algorithms (S) - Ktu Qbank
Dec 2019 CS302 - Design and Analysis of Algorithms (S) - Ktu Qbank
PART B
Answer any two full questions, each carries9 marks.
5 a) Solve using Recursion Tree method (5)
2
T(n)=3T(n/4)+n
b) Analyse the complexity of the following functions (4)
i)function(int n)
{ if (n==1) return;
for (int i=1; i<=n; i++)
{ for (int j=1; j<=n; j++)
{ printf("*"); break; }
}
}
ii) void function(int n)
{
int i = 1, s =1;
while (s <= n)
{
i++;
s += i;
printf("*");
}
}
Page 1 of 4
6 a) Construct a Red Black tree by inserting 10,20,30,15,16 and 27 into an initially (9)
empty tree and also delete 15,16 and 30 from the tree
7 a) Solve using Masters theorem (5)
i) T(n)=2T(n/4)+√n
ii) T(n)=7T(n/2)+ n2
b) Explain AVL rotations with examples (4)
PART C
Answer all questions, each carries3 marks.
8 Define spanning tree of a graph. Write the total number of spanning trees possible (3)
for a complete graph with 6 vertices.
9 Write the applications of BFS and DFS (3)
10 List and explain the characteristic properties associated with a problem that can be (3)
solved using dynamic programming.
11 Explain Divide and Conquer strategy. (3)
PART D
Answer any two full questions, each carries9 marks.
12 a) What are different classification of edges that can be encountered during DFS (4)
operation and how it is classified? Explain with example
b) Find strongly connected components of the digraph using the algorithm showing (3)
each step
c) Write the topological sorting for the DAG given below (2)
4
3
5
1
6
2
Page 2 of 4
Perform BFS traversal on the above graph starting from node A. If multiple node (2)
choices may be available for next travel, choose the next node in alphabetical order.
16 a) Formulate Fractional Knapsack Problem. Write Greedy Algorithm for fractional (5)
Knapsack Problem.
b) Find the optimal solution for the following fractional Knapsack problem. Given (5)
number of items(n)=4, capacity of sack(m) = 60, W={40,10,20,24} and
P={280,100,120,120}
17 a) Define NP hard and NP-Complete problems (4)
b) Write short notes on Polynomial time reductions with example (4)
c) Define class P and class NP (2)
Page 3 of 4
18 a) Define Travelling Salesman Problem (TSP). Explain the basic steps that are to (10)
be followed to solve TSP using branch and bound with an example.
19 a) Write the Kruskal’s algorithm for finding minimum cost spanning tree and explain (7)
the Kruskal’s algorithm with an example. Analyse the complexity of the algorithm.
b) Explain greedy strategy (3)
20 a) State and explain N-queens problem (2)
b) Draw the state space tree of 4-queens problem (5)
c) Define backtracking strategy (3)
****
Page 4 of 4