Algorithm 2016 Fall Quiz
Algorithm 2016 Fall Quiz
Quiz
1. (10%) Illustrate the BREATH-FIRST SEARCH algorithm and analysis its time
complexity.
Fig 1
Figure
Figure 2
3. (20%) (1) (10%) The matrix-chain multiplication problem can be stated as follows:
Given a chain <A1, A2,…, An> of n matrices, where for i=1,2,…,n, matrix Ai has
dimension pi-1 pi, fully parenthesize the product A1A2......An in a way that
minimizes the number of scalar multiplications. Give a dynamic-programming
algorithm to solve the problem and analyze its time complexity. (write pseudo
code)
(2) (10%) Suppose that you have 6 matrices: A1 has dimension 30 x 35, A2 has
dimension 35 x 15, A3 has dimension 15 x 5, A4 has dimension 5 x 10, A5 has
dimension 10 x 20, A6 has dimension 20 x 25. Please use your algorithm to
calculate the minimum number of scalar multiplications.(write table and answer)
4. In the algorithm SELECT, the input elements are divided into groups of 5. Will
the algorithm work in linear time if they are divided into groups of 7? Argue that
SELECT does not run in linear time if groups of 3 are used.
8. True or false
(I) 0-1 knapsack problem can be solved by greedy strategy
(II) In undirected graph, we apply DFS algorithm and we can get tree edges and
cross edges
(III) In top-down approach, memorization is a way to reduce some time cost in
exchange for space cost
(IV) Unweighted longest simple path problem does not satisfy the optimal
sub-structure
(V) If we apply topology sort for a directed graph, then using DFS on this graph
will produce no back edges