FINAL - short answer/equations Flashcards
Get an A+ on the final exam!!
Greedy choice property
The (a) greedy choice is contained in a globally optimal solution
Optimal substructure property
A globally optimal solution contains globally optimal solutions to its subproblems
Cardinality
The number of elements in a set
7 steps to solve a DP problem
- Define variables, 2. Express final numeric answer using variables, 3. Recurrence relation between the variables, 4. Dependency graph, 5. Figure out the order to solve the subproblems, 6. Pseudocode, 7. Reconstruct an actual optimal solution


What form does the recurrence have to take to use Master Theorem?

For Master Theorem, what is the level cost?

For Master Theorem, what is the # base cases?

For Master Theorem, what is the # levels?

For Master Theorem Case 1, what condition must be met?
Level cost is polynomially SMALLER than # base cases

What is the running time T(n) for Master Theorem Case 1 (level cost is poly SMALLER than # base cases)?

For Master Theorem Case 3, what condition must be met?
Level cost is polynomially LARGER than # base cases

For Master Theorem Case 3, what extra condition must be met?

What is the running time T(n) for Master Theorem Case 3 (Level cost is polynomially LARGER than # base cases)?

For Master Theorem Case 2, what condition must be met?
Level cost is in Big-Theta(# base cases)

For Master Theorem Case 2, what is the runtime T(n)?

What summation is this equation true for?


A BFS Tree is also…
The single source shortest path tree (where the weight of each edge is 1)
Tree edge (BFS)
An edge from a gray to a white node, where the white node is first being discovered (also called discovery edges)
BFS Applications
- Test if G is connected
- Compute a spanning tree of G
- Compute the connected components of G
- Compute the shortest path/distance between s and each vertex v in G
Parenthesis Lemma
- u is an ancestor of v iff [d[u], f[u]] SUPERSET OF [d[v], f[v]]
- u is a descendant of v iff [d[u], f[u]] SUBSET OF [d[v], f[v]]
- u and v are not related iff [d[u], f[u]] and [d[v], f[v]] are disjoint
What is a topological sort (of a DAG)?
A LINEAR ORDERING of all vertices in G such that vertex u comes before vertex v if (u, v) is in G. Topological sort creates a PARTIAL ordering (since multiple valid orders may exist)
For Prim’s algorithm, what is the key data structure?
A priority queue (min-heap) that is used to determine which node/edge to add to the tree next
For Dijkstra’s algorithm, what is the key difference from Prim and Kruskal?
Dijkstra’s algorithm uses a priority queue (like Prim) but uses the shortest distance to the root node as the key value for the PQ.
