Algorithms Test 2

Question 1. (25 points) A college professor has covered all the required material for a course and has time to cover 3 more topics. She has a list of 10 possible topics that she could cover. To help decide how to fill the remaining class time, she had each of her 20 students rank their first, second, and third picks from the list of 10 possible topics. Sample data from the student surveys would look like:

Students

Topics
A B C D E F G H I J
Student 1   3   1   2      
Student 2       2 3       1  
Student 3 2         1   3    
.

.

.

                   

Describe in English a greedy algorithm to select the 3 topics to be covered.

Question 2. (15 points) After Floyd's algorithm has run a while, it calculates D(2) of

    to
  D(2) : 1 2 3 4 5 6

from

1 0 10 18 7   23
2 5 0 8 13   13
3 9 4 0 17   4
4     1 0 6  
5         0 10
6 12 22 2 21 12 0

Calculate D(3) from the above D(2) matrix

    to
  D(3) : 1 2 3 4 5 6

from

1            
2            
3            
4            
5            
6            

Question 3. (15 points) For dynamic programming algorithms there are two general implementation approaches: (1) recursive memoization and (2) iterative. Explain when the recursive memoization approach should be used instead of the iterative approach.

Question 4. (30 points)

Design a backtracking algorithm to find the globally minimium assignment of n persons to n jobs. Use the following cost matrix in the description of your algorithm.

a) What should the search-space tree look like for this backtracking algorithm? (You do NOT need to draw the entire tree -- only enough to make it clear what you are doing).

b) Describe in English what pruning criteria can be used by a promising function when deciding if a node is to be pruned or not.

c) What state information is needed at each node in the search-space tree?

d) What information in your answer to part (c) could be kept global?

Question 4. (15 points) Consider the following best-first search Branch-and-Bound template.

1.  	procedure Branch_and_Bound ( T : stateSpaceTree;  var best : number)
2.      	var
3.     		PQ : priorityQueneOfNodes;
4. 		u, v : node;
5.	begin
6.		initialize(PQ);
7.		v := root of T;
8.		best := value(v);
9.		insert(PQ, v);
10.		while not empty(PQ) do
11.		     remove(PQ, v)
12.		     if bound(v) is better than best then
13.			for each child u of v do
14.			     if value(u) is better than best then
15.				best := value(u);
16.			     end if
17.			     if bound(u) is better than best then
18.				insert(PQ, u);
19.			     end if
20.			end for
21.		       	end if
22.		end while
23.	end Branch_and_Bound

a) On line 11, node v is removed from the priority queue PQ. If the boolean expression on line 12 is False, then node v is discarded. Why can node v be discarded?

b) When would you expect the best-first search Branch-and-Bound approach to be faster than backtracking for a specific problem?