QN 5
QN 5
Candidates are required to give their answers in their own words as far
as practicable.
The figures in the margin indicate full marks.
Attempt all the questions.
1
4. a) Apply dynamic programming approach to find the shortest path in 8
the following multistage graph.
Also show that greedy method is not suitable for this kind of
problems.
b) What is optional binary search tree? Provide the algorithm for finding 7
optimal tree with a suitable example.
5. a) Design an algorithm which finds the second largest element in an 7
array of n integers. Determine the number of comparisons the
algorithm makes in the worst case.
b) Describe the single source shortest path problem having negative 8
weight graph. Write the algorithm to compute shortest path with
negative edge cost. Calculate its complexity.
6. a) Explain backtracking algorithm and write down the backtracking 7
algorithm for N-queen problem.
b) Let 𝑊 = {5, 7, 10, 12, 15, 18, 20} and 𝑚 = 35. Find all possible 8
subsets of 𝑤 that sum to 𝑚 using backtracking. Also draw the portion
of the state space tree that is generated.
7. Write short notes on: (Any two) 2×5
a) 0/1 Knapsack Problem.
b) Bi-connected Components.
c) Hamilotinian Cycle.