Algorithm Analysis (CSC 301 2015F) : Outlines

Outline 03: Reflective Activities


Held: Wednesday, 2 September 2015

Back to Outline 02 - Asymptotic Analysis. On to Outline 04 - Asymptotic Algorithm Analysis, Continued.

Summary

We reflect on the learning goals of the first two days of class and ground our understanding in a variety of exercises.

Related Pages

Overview

Administrivia

Upcoming Work

Extra Credit

Academic

Peer

Dijkstra's shortest-path algorithm, revisited

Slightly modified version of the version from Wikipedia, available at https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm.

 1  function Dijkstra(Graph, source, target):
 2
 3    dist[source] = 0              // Distance from source to source
 4    prev[source] = undefined      // Previous node in optimal path initialization
 5
 6    create vertex set Q           // Unvisited nodes
 7
 8    for each vertex v in Graph:   // Initialization
 9      if v != source:             // (unvisited nodes)
10        dist[v] = INFINITY        // Unknown distance from source to v
11        prev[v] = UNDEFINED       // Previous node in optimal path from source
12      add v to Q                  // All nodes initially in Q (unvisited nodes)
13      
14    while Q is not empty:
15      u = vertex in Q with min dist[u]    // Source node in the first case
16      remove u from Q 
17          
18      for each neighbor v of u:   // where v is still in Q.
19        alt = dist[u] + length(u, v) // length of path through u
20        if alt < dist[v]:         // A shorter path to v has been found
21          dist[v] = alt 
22          prev[v] = u 
23
24    return dist[target]           // or the path using prev

Algorithm design strategies, revisited

Greedy algorithms

Asymptotic analysis, reviewed

Additional properties of Big-Oh