CST306 Algorithm Analysis and Design, May 2024
CST306 Algorithm Analysis and Design, May 2024
: Name:
PART A
Ansver oll questions, each carries 3 morlcs. Marks
Explain the best case and worst case of a search operation in a binary search tree. (3)
2 Is n2 e o(nz)? (Little o). Justiff your answer. (3)
3 Explain about any two cases of rotations in an AVL-Tree with proper example. (3)
4 Obtain the topological sort order ofthe given graph G=(V,E) (3)
Give the control abstraction of divide and conquer algorithm design strategy. (3)
Consider an instance of fractional knapsack problem rvith 3 objects and capaciq'' (3)
20Kg. The profit and weight vectors corresponding to the 3 objects respectively
are ( 10, 15, 20) and (8, 10, 20). Compute an optimal solution to this instance of
fractional knapsack problem. What will be the profit earned corresponding to
this solution?
J+ What are the main steps involved in solving a computational problem using the {3)
algorithm design strategy Dynamic Programming.
8 List any three diffenences between Backtracking and Branch and Bound (3)
strategies.
9 Let G = (V, E) be a graph with vertex set V and edge set E. Define the (3)
Page lof4
12(xrcsT306052302
PART B
Answer onefull queslionfrom each module, each curries Il nurks.
Module I
il a) Illushate the best case, wSrst case and average case of linear search algorithm (7)
with proper examples.
T(n)= 2T(n/2) + |
OR
12 a) Solve the following recurrence using substitution method. (8)
r(n) = zt + cnz
Q)
b; Solve the following recurrences using Master's theorem. (6)
,{
Dr(n) =zr(i)+r
iD r(n) = zr (*) + ttn
Module II
13 a) Create an AVL tree by inserting the values from l to 8 in increasing order. (7)
b) Give an algorithm for computing connected components in a graph using (7)
Disjoint Set data structur€ operations. Explain the working of this algorithm on
thc graph given below.
oRr
14 a) Give an appropriate algorithm for Oefr First Search in a given connected (e)
graph. Derive the time complexity of the algorithm with proper justification.
b) What are strongly connected components of a directed graph? Explain with an (s)
example.
PageZof4
1200csT!to6052302
Module III
15 a) Apply Dijkstar's algorithm on the given graph to find the shortest path to all (6)
destinations starting from verQx with label I
b) Write Kruskal's algorithm to find the minimum cost spanning tree ofa given (8)
weighted connected graph. What is the time complexity of the algorithm? Justifr
your answer.
OR
16 a) Formally state the fractional knapsack problem. Give an algorithm for (9)
computing an optimal solution to this problem using greedy strategy. What is its
tirne complexity? Justify your answer.
b) Give the control abstraction of greedy algorithm design strategy. (5)
Module W
l7 a) Given a chain of 4 matrices < Al, A2, A3, A4 > with dimensions <5 x 4>, <4 (9)
t x 6>, <6 x 2>, and 4 x 7>. Fully parenthesisze the given matrices so that the
Page 3of4
12(xrcST3060.52302
Construct the weight adjacency matrix of the given graph. Apply the Floyd-
Warshall algorithm to construct the matrix Dzthat represents the shortest paths
distance between all vertices i and j (l <= i <: 5 and I <= j <= 5) through
intermediate vertices I and?.
b) Define n{ueens problan. Draw the state space diagram of 4nueens problem by (6)
vertex cover of G? Also prove that the decision version of vertex cover problem
is NP-Hard.
b) Define Bin Packing problem. Give the First Fit heuristc approximation for this (6)
Page 4of 4