{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm3sol

# Midterm3sol - COT 5405 Analysis of Algorithms Spring 2010...

This preview shows pages 1–4. Sign up to view the full content.

COT 5405 Analysis of Algorithms, Spring 2010. Midterm 3 April 8, 2010 Name: UFID: Notes This is a closed-book exam. No calculator. You have 100 minutes for the exam. If the problem necessitates writing an algorithm, you must first informally describe the algorithm, in brief, in a paragraph. You can choose to follow this up with pseudocode that formally describes the algorithm. We will peruse your pseudocode only if your English description is not clear. Write your name on the top right hand corner of your exam. Be sure to write your last name as the last word in your name. If you are designing an algorithm, you must write a formal proof of correctness. Please write legibly. 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
1. [1 page][33points] The following graph with weights on edges is given. Apply Floyd-Warshall algo- rithm to compute shortest path between all pairs of vertices (only the distance of the path, not the path itself). Provide a weight matrix at each iteration. Floyd-Warshall recurrence relation is as below. Let D ( k ) = ( d ( k ) i,j ) be the weight matrix after k th iteration, d ( k ) i,j = min ( d ( k - 1) i,j , d ( k - 1) i,k + d ( k - 1) k,j ) , k 1 d (0) i,j = 0 if i = j weight of edge ( i, j ) if i 6 = j otherwise 1 3 5 4 2 3 1 1 -2 5 -1 3 Solution: D = 0 2 1 0 0 3 0 3 - 2 2 4 1 0 - 1 - 1 9 6 5 0 4 12 9 8 3 0 2
2. [1 page][33points] You need to go over a river by canoe and there are n trading posts along the river.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

Midterm3sol - COT 5405 Analysis of Algorithms Spring 2010...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online