1 / 12

CS 101 – Nov. 30

CS 101 – Nov. 30. Communication, continued TCP/IP review Dijkstra’s shortest path algorithm Download speeds. Snooping. The “dark side” of TCP/IP Web site can track you by IP address Localized marketing Privacy concerns Anonymous IP servers Ex. “Anonymouse”. Dijkstra’s algorithm.

carys
Télécharger la présentation

CS 101 – Nov. 30

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 101 – Nov. 30 Communication, continued • TCP/IP review • Dijkstra’s shortest path algorithm • Download speeds

  2. Snooping The “dark side” of TCP/IP • Web site can track you by IP address • Localized marketing • Privacy concerns • Anonymous IP servers • Ex. “Anonymouse”

  3. Dijkstra’s algorithm • How do you find the shortest path in a network? • General case solved by Edsger Dijkstra, 1959 4 7 9 6 8 7 4 3 2 3 1 6

  4. A 4 7 • Let’s say we want to go from “A” to “Z”. • The idea is to label each vertex with a number – its best known distance from A. As we work, we may find a cheaper distance, until we “mark” or finalize the vertex. • Label A with 0, and mark A. • Label A’s neighbors with their distances from A. • Find the lowest unmarked vertex and mark it. Let’s call this vertex “B”. • Recalculate distances for B’s neighbors via B. Some of these neighbors may now have a shorter known distance. • Repeat steps 3 and 4 until you mark Z. 2 B C 3 4 Z

  5. A 4 7 First, we label A with 0. Mark A as final. The neighbors of A are B and C. Label B = 4 and C = 7. Now, the unmarked vertices are B=4 and C=7. The lowest of these is B. Mark B, and recalculate B’s neighbors via B. The neighbors of B are C and Z. • If we go to C via B, the total distance is 4+2 = 6. This is better than the old distance of 7. So re-label C = 6. • If we go to Z via B, the total distance is 4 + 3 = 7. 2 B C 3 4 Z

  6. A 4 7 Now, the unmarked vertices are C=6 and Z=7. The lowest of these is C. Mark C, and recalculate C’s neighbors via B. The only unmarked neighbor of C is Z. • If we go to Z via C, the total distance is 6+4 = 10. This is worse than the current distance to Z, so Z’s label is unchanged. The only unmarked vertex now is Z, so we mark it and we are done. Its label is the shortest distance from A. 2 B C 3 4 Z

  7. A 4 7 Postscript. I want to clarify something… The idea is to label each vertex with a number – its best known distance from A. As we work, we may find a cheaper distance, until we “mark” or finalize the vertex. When you are mark a vertex and look to recalculate distances to its neighbors: • We don’t need to recalculate distance for a vertex if marked. So, only consider unmarked neighbors. • We only update a vertex’s distance if it is an improvement: if it’s shorter than what we previously had. 2 B C 3 4 Z

  8. Shortest Paths • Dijkstra’s algorithm: What is the shortest distance between 2 points in a network/graph ? • A related problem: What is the shortest distance for me to visit all the points in the graph and return home? This is called the traveling salesman problem. Open question in CS: why is this problem so hard?

  9. B 8 6 9 12 A 2 C 5 4 6 3 E D 4

  10. Measuring speed • Overhead = prepare & assemble message • Flight time = first bit to arrive at destination • Bandwidth = max rate to propagate data (cruising speed) • Total time = overhead + flight time + (msg size)/bandwidth

  11. How much longer?

  12. Examples

More Related