Final Review
for CMPS 2200, Fall 2014
Relevant Material:
- All material from 8/25/14 until 12/4/14 (inclusive).
- This includes material covered in the lectures, homeworks 1 - 9, and the two projects.
- Review for the Test
- New Material:
- Representation of Graphs:
- Adjacency matrix
- Adjacency lists
- Handshaking lemma
- Sample Questions
- Come up with an algorithm to convert given adjacency
lists to a matrix or vice versa.
- Graph Traversal: 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|) [if adjacency lists are given]
- Depth First Search:
- Runtime: O(|V|+|E|) [if adjacency lists are given]
- 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 time using BFS
- Runtimes of BFS and DFS when different variants of
graph representations (adjacency lists vs. adjacency matrix) are used.
- Single Source Shortest Paths
- Dijkstra: Works only for non-negative edge weights.
- Runtime: Θ(|V|)·T EXTRACT-MIN + Θ(|E|)·TDECREASE-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. Funtime 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.
- Minimum Spanning Tree(MST)
- Prim
- Runtime: Θ(|V|)·TEXTRACT-MIN + Θ(|E|)·TDECREASE-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.
- Amortized Analysis:
- Aggregate analysis, accounting method
- Dynamic tables, binary counter
- Sorting
- 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)
- Counting Sort:
- Decision Trees:
- For a given (sorting or searching) algorithm
- Lower bound for comparison sorting (or searching) algorithms.
- 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 Questons
- For a given problem, show if it is in NP or not, justify
your answer.
- Definition and basic properties of reductions