You are on page 1of 3

North South University

Department of Electrical and Computer Engineering


CSE 373: Design and Alaysis of Algorithms
Section 1,2
Spring 2020
End of Semester Assignment
Due: 4th June 2020 via Google classroom

Instructor: Dr. Sifat Momen

There are altogether of 5 questions comprising of a total of 65 marks. This assignment has a
total of 3 pages.You should submit your solution in a single pdf file.

1. This question is about the Rod Cutting Problem.


(a) (6 points) State the rod cutting problem. Explain how brute force technique can be
used to solve the rod cutting problem. What is the disadvantage of solving this problem
using this method? Explain.
(b) (6 points) Derive a recurrence relation to solve the rod cutting problem and show that
the problem has the optimal substructure property.
(c) (3 points) With the aid of an example, explain whether the problem can be solved using
greedy algorithm.
(d) (5 points) Provide a DP solution to the rod-cutting problem.

2. The longest common subsequence (LCS) problem is the problem of finding the longest
subsequence common to all sequences in a set of sequences (often just two sequences).
(a) (5 points) Provide a brute force solution to this problem. Explain carefully why this is
not a desirable solution.
(b) (5 points) Determine the LCS of your first name and last name using dynamic pro-
gramming.
(c) (10 points) Determine the levenshtein distance between your first name and last name.

3. (5 points) State the differences between the following classes of problems: P, NP, NP-complete,
NP-hard. Use venn-diagram to illustrate the connection between these.

1
4. Figure 1 shows how roads are connected. Edges in the graph represent the distance between
the vertices.

Figure 1: Road networks

(a) (7 points) Dijkstra’s algorithm solves the SSSP problem. Explain what do you understand
by this. Use Dijkstra’s algorithm to determine the shortest path from the vertex d to all
other vertices.
(b) (6 points) Use Bellman-Ford algorithm to determine the shortest path from the vertex d
to all other vertices.
(c) (2 points) Compare the differences between the two algorithms (i.e. the Dijkstra’s algo-
rithm and the Bellman-Ford algorithm)

Page 2
5. (5 points) Graph coloring, with minimum number of colors, is an NP complete problem. The
following is an algorithm that provides a near-optimal coloring of vertices such that no two
adjacent vertices in a given graph has the same color.

Algorithm 1: Algorithm for graph coloring


1. Order the nodes V1 , V2 , ..., Vn
2. Order the colors C1 , C2 , ..., Cm
3. for i = 1, 2, ..., n do
3.1 Assign the lowest color to vi
end

Apply the algorithm stated in algorithm 1 to the following graph. What is the time complexity
of this algorithm and how many colors do you require to color this graph?

Figure 2: An undirected graph

Page 3

You might also like