solmidterm2Sol

# solmidterm2Sol - Solution to Midterm 2 Fall 2008 cs170...

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

Solution to Midterm 2 Fall 2008 cs170 Problem 1 [60 points] 1. 0.55 0.3 0.1 0.05 2. True 3. 3 1 1 4. -5 20 22 Dijkstra outputs (S,A) and (S,B) as the final tree with shortest path distances of 20 , and 22 respectively. In Dijkstra algorithm once a node is removed from the priority queue, it means that its shortest distance is finalized and other nodes cannot update it. Therefore since A is removed before B then the updates of B do not have any effect on A . Here is how the priority queue works: Initially there are A(0), B( ∞ ), A(∞ ) on the queue. Then A is removed and B( ∞ ) , A( ∞ ) are updated to B(22), A(20) . Now A is removed from the priority queue and since it does not have any children no updates are done. The value of A so far is 20 and it is not going to change because A is removed from our priority queue. Finally B is removed from the priority queue, but there are no nodes to update are removed from our priority queue.

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.

## This note was uploaded on 04/30/2010 for the course L&S 101 taught by Professor Chow during the Spring '10 term at Berkeley.

### Page1 / 3

solmidterm2Sol - Solution to Midterm 2 Fall 2008 cs170...

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

View Full Document
Ask a homework question - tutors are online