Professional Documents
Culture Documents
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.
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.
(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.
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?
Page 3