Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
63 Cards in this Set
- Front
- Back
4 steps of algorithm analysis |
1) define the parameters and input size 2) define the basic operation 3) determine how the number of operations varies with different inputs 4) express as a closed form solution in terms of input size |
|
Graph |
data structure composed of vertices and edges. G = (V, E) |
|
Directed Graph
|
graph whose edges have a direction |
|
in-degree |
number of edges going into a vertex |
|
out-degree |
number of edges going out of a vertex |
|
weighted graph |
graph whose edges have a weight value |
|
graph path |
a sequence of vertices and edges that go from a starting vertex to an ending vertex |
|
acyclic graph |
graph with no cyclical paths |
|
path length |
the number of edges in a path |
|
depth |
the number of edges separating one vertex from another |
|
Euler Path |
a path in a graph that uses all edges exactly once |
|
Hamilton Path |
a path in a graph that uses all vertices exactly once |
|
source |
a vertex with in-degree 0 |
|
sink |
a vertex with out-degree 0 |
|
flow network |
graph with 1 source, 1 sink, and where the total flow into any other vertex equals the total flow out of the vertex. |
|
flow value |
the sum of the flow leaving a source, or entering a sink |
|
cut |
given a flow network graph G = (V, E), separate V into two subsets X and Xbar where X contains the source and Xbar contains the sink. Then the cut is the set of all edges whose tails are in X and whose heads are in Xbar. |
|
cut capacity |
The sum of all capacities of the edges in the cut |
|
Depth First Search (DFS) |
searching a tree or graph from a starting vertex and searching "deep". Often implemented recursively |
|
Breadth First Search (BFS) |
searching a tree or graph from a starting vertex and searching all children of a node before continuing. Often implemented with a Queue. |
|
Tree edge |
an edge used in traversal during a BFS or DFS |
|
Back Edge |
an edge that goes to an ancestor vertex in the DFS tree |
|
Forward edge |
an edge that goes to a previously visited, but non-ancestor vertex in a DFS tree |
|
cross edge |
an edge that goes to a previously visited vertex in a BFS tree |
|
Tree |
data structure composed of nodes that have none or more children |
|
tree leaf |
a node with no children |
|
tree height |
the number of levels in a tree (starting with 0) |
|
spanning tree |
a tree that is inside a graph that visits all vertices |
|
minimal spanning tree |
a spanning tree of a weighted graph with the smallest total weight of the summed edges |
|
min heap |
data structure that allows easy access to small values |
|
max heap |
data structure that allows easy access to large values |
|
heap: sift down |
moving a node of a heap down the tree to its correct position |
|
heap: sift up |
moving a node of a heap up the tree to its correct position |
|
optimal substructure |
the relation that defines how to 'build' a dynamic programming solution |
|
Class P |
the set of problems that can be solved by a polynomial time algorithm |
|
Class NP |
the set of problems that, given a potential solution, can be verified in polynomial time |
|
NP Complete |
a problem D is NP complete if it is in NP and all other problems in NP can be polynomially reduced to D. |
|
polynomial reduction |
problem D1 is polynomially reducible to problem D2 if there exists transformation T from D1 -> D2 that maps all 'yes' instances of D1 to a 'yes' instance of D2 and all 'no' instances of D1 to a 'no' instance of D2 in polynomial time. |
|
big O definition |
if f(n) and g(n) are functions, then f(n) is in O(g(n)) if there exist c, n_0 such that f(n) < c * g(n) for all n > n_0. |
|
big Omega definition |
if f(n) and g(n) are functions, then f(n) is in Omega(g(n)) if there exist c, n_0 such that f(n) > c * g(n) for all n > n_0. |
|
big Theta definition |
if f(n) and g(n) are function, then f(n) is in Theta(g(n)) if there exist c_1, c_2, n_0 such that c_1 * g(n) < f(n) < c_2 * g(n) for all n > n_0. |
|
sum from i=k to n of (1) |
= n - k + 1 |
|
sum from i = 1 to n of (i) |
= [n(n+1)]/2 |
|
sum from i = 1 to n of (i^2) |
= [n(n+1)(2n+1)]/6 |
|
sum from i = 1 to n of (i^k) |
~= [n^(k+1)]/(k+1) |
|
sum from i=0 to n of (a^i) |
= [a^(n+1)-1]/(a-1) |
|
Master Theorm |
Given time function T(n) = a T(n/b) + n^d) log_b(a) < d ==> T(n) in Theta(n^d) log_b(a) = d ==> T(n) in Theta(n^d * log(n)) log_b(a) > d ==> T(n) in Theta(n ^ log_b(a)) |
|
Traveling Salesperson |
Given a weighted graph G = (V, E), what is the shortest Hamilton Path? |
|
Knapsack Problem |
Given a set of items I, each with a value and weight and a knapsack with a capacity, what is the most valuable subset of items that fit into the knapsack? |
|
Brute force Traveling Salesman |
pick starting vertex. generate all permutations for the other (n - 1) vertices, for each permutation, check if it makes a circuit and is a new smaller distance |
|
Brute Force Knapsack |
generate all subsets of items, for each subset, check if it can fit in the knapsack and is a new highest value. |
|
Topological Sort |
a linear ordering of vertices of a directed graph so that there are no paths from any given vertex to any other vertex previously in the listing |
|
Topological Sort DFS implementation |
using a DFS of the graph, add vertices as they are "left" in reverse order. |
|
Topological Sort Source Removal implementation |
make a list of all vertices and their in-degrees. add one with 0 in-degree, and decrament the in-degrees of all adjacent vertices. repeat until all are added.
|
|
Lomuto's partitioning algorithm |
two counters, each move left -> right. If Lead counter is larger than p, increase, if it is smaller, increase lower counter, swap, increase lead counter. |
|
quicksort partition |
two counters move in from each end. while left is smaller than p, increase. While right is larger than p, decrease. swap left and right. repeat until left and right cross. |
|
Heap sort |
build heap in array. continuously remove from heap and place at the position after the last element in heap. |
|
Cut Property |
For a weighted graph G = (V, E), if V is 'cut' into X and V - X, then the smallest edge between X and V-X must be part of the MST for G. |
|
Sequence Alignment Algorithm |
table is m x n with sequences along sides. initialize table T. Then, each cell at i, j is max of: - T[i, j - 1] + 2 - T[i -1, j] + 2 - T[i - 1, j - 1] + C[i,j] where C[i,j] is 0 if letters at i and j are same, 1 otherwise. |
|
Max Flow, Min Cut theorem |
The maximum flow for a flow network is equal to the min cut of that same network |
|
Stable Marriage |
Start with everyone free, as long as there are free men: a free man proposes to his highest preferred single lady if she is free, she accepts if she is taken, but the new man is better, the old man is now free if she is taken, but the new man is worse, he remains free continue until all men are taken |
|
State Space Tree |
A tree that represents all possible configurations of a problem |
|
backtracking |
walking backwards through a state space tree to construct a solution |