Graph Representation

Shortest path representation

Edge relaxation

Manually tracing Bellman–Ford and Dijkstra's algorithm. This should be easy.

Bellman-Ford algorithm

Dijkstra's algorithm

Recommended Problems

C level

  1. Simulate Dijkstra's algorithm on the edge-weighted digraph below, starting from vertex 0.
    1. Give all the distTo[] and edgeTo[] values that result.
    2. What is the maximum number of items in the priority queue?
    3. What is the last vertex popped from the priority queue?
    4. What letter is spelled out by the edges of the shortest-path tree (SPT) computed by Dijksta's algorithm?
  2. Textbook 4.3.1 and 4.4.1

B level

  1. Spring 2012 Final, #5
  2. Fall 2012 Final, #5
  3. Fall 2011 Final, #4
  4. Think about how to solve the undirected version of the shortest paths problem. Why is it easy for graphs with positive edge weights? Why is it hard if we include negative edge weights?
  5. Textbook 4.4.25
  6. Since Prim's algorithm and Dijkstra's algorithm are so similar, why do we need to check for cycles in Prim's, but not in Dijkstra's?
  7. Textbook 4.4.42 and 4.4.44

A level

  1. Textbook 4.4.34
  2. Textbook 4.4.37