You are on page 1of 2

NATIONAL INSTITUTE OF TECHNOLOGY, ROURKELA

MID-TERM EXAMINATION, SPRING SEMESTER- 2019


ANSWER ANY FIVE QUESTIONS
All Parts of a question should be answered at one place.
SUBJECT: Design and Analysis of Algorithms DEPT. CODE: CS 2006
FULL MARKS : 50 Duration of Examination: 3 Hours

1[a] Write an algorithm to solve the make-change problem using dynamic programming? Suppose
there are n types of coin denominations, d1, d2, …, and dn. (We may assume one of them is penny.)
There are infinite supplies of coins of each type. The problem is to make change for an arbitrary
amount j using the minimum number of coins. Comment on time and space complexity of the
algorithm

1[b] Define single source shortest path problem? Write a greedy algorithm so that it obtains the
shortest paths in addition to the lengths of these paths in an undirected weighted Graph. What is
the computing time of your algorithm? Find the shortest distance from A to H on the network
below

[5+5]
2[a] Express, finding minimum spanning tree of an undirected connected graph as an optimization
problem. Kruskal’s algorithm for finding a minimum spanning tree employs a minheap to store the
candidate edges. If a graph has m edges, explain why the time complexity for this algorithm must
be O(m logm). In Kruskal's method for finding a minimum spanning tree, how does the algorithm
know when the addition of an edge will generate a cycle?
2[b] Write TVS algorithm for a directed binary tree with weighted edge. Use the algorithm for the given
network and a loss tolerance level  =10, determine the optimal placement of boosters in the
network.

2 3 4

5 6 7

8 9 1 1
0 1
[5+5]
3[a] A single execution of Floyd's algorithm will find the lengths (summed weights) of the shortest paths
between all pairs of vertices, though it does not return details of the paths themselves. Write a
Page 1 of 2
dynamic programming algorithm to find the paths. Can the Floyd’s Algorithm applicable for the
graph with cycles of negative length

3[b] Explain the generic method for branch and bound algorithms. How does branch and bound method
solve the 0/1 Knapsack problem? Use the following instance n = 5, (p1, p2, p3, p4, p5) = (10,15, 6, 8,
4), (w1, w2, w3, w4, w5) = (4, 6, 3, 4, 2), and m = 12 to explain branch and bound algorithm. Will the
branch and bound algorithm perform better that the dynamic programming solution? Justify.
[5+5]
4[a] Sum of subsets problem is to find subset of elements that are selected from a given set
whose sum adds up to a given number K. Define solution, explicit constraints, and implicit
constraints of Subset Sum problem. Suggest a recursive backtracking algorithm for Sum of subsets?

4[b] Suggest a greedy solution for the container loading problem to the case when there are two ships.
Does your Algorithm always generate optimal solutions? Comment on solution space and
complexity of your algorithm?
[5+5]
5[a] Define the principal of optimality? Explain the basic 4-step process to solve optimization problem
under dynamic programming paradigm? Use LCS problem to explain this 4-step process with
appropriate algorithm?

5[b] Formulate the container loading as an optimization problem. Suggest a greedy algorithm to find
solution to the container loading. Suppose you have 6 containers whose weights are 50, 10, 30, 20,
60, and 5 and a ship whose capacity is 100. Use the algorithm to find an greedy solution to this
instance of the container loading problem.
[5+5]
6[a] What are the main steps of a backtracking algorithm? What is dead-end in a backtracking? State the
different constraints to be satisfied while solving a optimization problem using backtracking?
Discuss how BACKTRACKING is used to solve 4-queens problem where solution space is organized
as a tree.

6[b] Discuss the structure of knapsack problem? Explain how this problem can be solved using Dynamic
programming. Find an optimal solution the knapsack problem with instance n =7, m=15 with ( P 1,
P2, .., P7) = (10, 5, 15, 7, 6, 18, 3) and (w1, w2, … , w7) = (2, 3, 5, 7, 1, 4, 1).
[5+5]
7[a] What is the “Optimal Storage on tape” problem? Write a greedy algorithm for assignment of n
program on M number of tape? Find an optimal placement for 13 programs on three tapes T0, T1,
and T2, where the program are of length 12, 5, 8, 32, 7, 5, 18, 26, 4, 3, 11, 10, and 6.

7[b] Suppose that we want to multiply four matrices, A, B, C, D, of dimensions 5020, 201, 1 10, and
10 100, respectively. Multiplying an mn matrix by an np matrix takes mnp multiplications.
Determine the optimal order, if we want to compute ABCD using dynamic programming.
[5+5]
8[a] Let T be a tree with root v. The edges of T are undirected. Each edge in T has non-negative length.
Write an algorithm to determine the length of the shortest paths from v to the remaining vertices
of T. Your algorithm should have complexity O(n), where n is the number of vertices in T.

8[b] Compute the longest common subsequence between the two strings “HUMAN” and
“CHIMPANZEE”. What is the complexity of the LCS finding algorithm? Explain that LCS algorithm
yields optimal solution.
[5+5]
--------------------------------------- Good luck ---------------------------------------

Page 2 of 2

You might also like