Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
courses:cs211:winter2011:journals:wendy:chapter6 [2011/03/30 02:44] – shangw | courses:cs211:winter2011:journals:wendy:chapter6 [2011/04/03 05:29] (current) – shangw | ||
---|---|---|---|
Line 70: | Line 70: | ||
It indeed takes O(m+n) space. The recurrence relationship is: T(m, | It indeed takes O(m+n) space. The recurrence relationship is: T(m, | ||
I really like the idea and the readability is 9. | I really like the idea and the readability is 9. | ||
+ | |||
+ | ==== Section 8: Shortest Paths in a Graph===== | ||
+ | This is a variation of the shortest paths in a graph problem with only positive edges. In this extended problem, we allow negative-weighted edges; however we still do not allow a negative cycle-because it can just go on forever around the cycle and go to negative infinitive, and become meaningless. | ||
+ | When there is negative edges, it is easy to come up with a counter example that our old greedy algorithm no longer works. Then the book tries to modify the greedy algorithm by adding a constant M big enough to each edge so as to make them all positive, which is easy to be seen wrong, too. Hence, we need to turn to dynamic programming. | ||
+ | The recurrence is: | ||
+ | OPT(i, | ||
+ | This algorithm, like many other dynamic programming, | ||
+ | In addition, to save both time and space, we set a stopping signal: when we run into 2 same columns consecutively, | ||
+ | The readability is 8. | ||
+ | |||
+ | ==== Section 9: Shortest Paths and Distance Vector Protocols===== | ||
+ | This is section introduces an algorithm that improves the shortest paths algorithm from section 8. | ||
+ | First we observe the shortage of the original algorithm: it is a pull-based algorithm, and in each iteration, each node will contact all its neighbors and " | ||
+ | Then it continues to discuss some associated concerns with the distance vector protocol. In real life scenario, if one of the edges is deleted, which totally cut-off all the connections between a node a and the ending node b, the distance vector protocol will not cease updating M[a] and never realize there is no path available. And this, of course, can be problematic. | ||
+ | The way to solve it is to keep track of the big picture: each node not only storing knowledge of its neighbor but the entire network to ensure there actually exists a path. The extra storage will take over more space but is indeed necessary. | ||
+ | Readability is 7. | ||