Final Review for CMPS 2200, Fall 2015

Relevant Material:

  1. Topics from the Midterm Review
  2. Greedy Algorithms
    • Greedy Strategies:
      • Repeatedly identify the decision to be made (recursion)
      • Make a locally optimal choice for each decision
    • Greedy does not always work.
    • Sample Questions:
      • Short questions or true/false about the concepts
      • Come up with a greedy solution to a problem or with a counter-example why a greedy solution does not work
  3. Representation of Graphs:
    • Adjacency matrix
    • Adjacency lists
    • Handshaking lemma
    • Sample Questions
      • Come up with an algorithm to convert given adjacency lists to an adjacency matrix or vice versa.
  4. Graph Traversal: Assume the graph G=(V,E) is represented using adjacency lists. Note that the assignment of timestamps depends on the order of vertices in the adjacency lists or matrix. For example, if vertices are alphabetically ordered then if a has b, c and d in its list then b will be visited/discovered first from a, not c or d.
    • Breadth First Search:
      • Runtime: O(|V|+|E|)
    • Depth First Search:
      • Runtime: O(|V|+|E|)
      • DFS edge classification
      • Directed Acyclic Graph (DAG) and topological sort
    • Sample Questions:
      • For a given graph, give discover/finish times using DFS.
      • For a given graph, give visit times using BFS.
      • Runtimes of BFS and DFS when different variants of graph representations (adjacency lists vs. adjacency matrix) are used.
  5. Single Source Shortest Paths
    • Dijkstra: Works only for non-negative edge weights.
      • Runtime: Θ(|V|)·T_EXTRACT-MIN + Θ(|E|)·T_DECREASE-KEY
      • Runtimes using different variants of graph representations and priority queues (linked list, min-heap or array)
    • Bellman-Ford: It works for any edge weights and can detect negative weight cycles.
      • Runtime: O(|V||E|)
      • For a DAG, run Topological Sort and then one round of Bellman-Ford. Runtime O(|V|+|E|)
    • Sample Questions:
      • For a given graph, run Dijkstra's/Bellman-Ford algorithm and show all different steps (vertex weights, priority queue, predecessor array)
      • Modify Dijkstra's/Bellman-Ford's algorithm for special cases of graphs to improve runtime or space.
  6. All Pairs Shortest Paths
    • Floyd-Warshall:
      • Runtime: O(|V|^3) [when adjacency matrix is given]
    • Dijkstra: Run single source Dijkstra once for each vertex as source.
    • Bellman-Ford: Run single source Bellman-Ford once for each vertex as source.
      • Runtime: O(|V|^2|E|)
    • Sample Questions
      • Analyze the runtime of Floyd-Warshall if adjacency lists are given instead of adjacency matrix.
  7. Minimum Spanning Tree (MST)
    • Prim:
      • Runtime: Θ(|V|)·T_EXTRACT-MIN + Θ(|E|)·T_DECREASE-KEY
      • Runtimes using different variants of graph representations and priority queues (linked list, min-heap or array)
    • Kruskal:
      • Runtime: O(|E|log|E|) which comes from sorting all the edges.
    • Sample Questions:
      • For a given graph run Prim's algorithm and show all different steps (vertex weights, priority queue, predecessor array)
      • For a given graph run Kruskal's algorithm and show the subsets of different steps.
  8. Amortized Analysis & Union-Find:
    • Aggregate analysis, accounting method
    • Dynamic tables, binary counter
    • Union-Find:
      • Union-find data structure definition (operations)
      • Union-find: List implementation, tree implemention
      • Union by weight/rank, path compression
      • Ackermann function, inverse Ackermann function
  9. Sorting and Order Statistics
    • Decision Trees:
      • For a given (sorting or searching) algorithm
      • Lower bound for comparison sorting (or searching) algorithms.
    • Counting Sort:
      • Runtime: O(n+k)
    • Randomized Algorithms
      • Expected runtime vs. average runtime, best-case runtime, and worst-case runtime
    • Quicksort
      • Runtime:
        • Best case: O(n log n) [When each pivot partitions the array into two roughly equal pieces]
        • Worst case: O(n^2) [When the array is already sorted either increasing or decresing order]
        • Average Case: O(n log n)
    • Order Statistics
      • Select Algorithm: to select the i-th smallest element
        • Randomized Select: Runtime
          • Worst Case: O(n^2)
          • Average Case/Expected Runtime: O(n)
    • P and NP
      • Definition of P, NP, NP-hard, NP-complete
      • Reductions, NP-complete problems (SAT, Clique, TSP, Vertex Cover, Independent Set)
      • Sample Questions
        • For a given problem, show if it is in NP or not, justify your answer.
        • Definition and basic properties of reductions


Practice Problems from the Book: