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;
85 Cards in this Set
- Front
- Back
insert sorted array |
n |
|
look up sorted array |
log n |
|
deleted sorted array |
n |
|
getMin sorted array |
1 |
|
getMax sorted array |
1 |
|
getMax unsorted array |
n |
|
getMin unsorted array |
n |
|
deleted unsorted array |
n |
|
look up unsorted array |
n |
|
insert unsorted array |
1 |
|
inser heap |
logn |
|
look up heap |
n |
|
delete heap |
n |
|
heap getMin |
1 |
|
heap getMax |
n |
|
insert avl |
log n |
|
lookup avl |
log n |
|
delete avl |
log n |
|
getMin avl |
log n |
|
getMax avl |
log n |
|
chaining hash insert |
1 |
|
chaining hash lookup |
n |
|
chaining hash delete |
n |
|
chaining hash getMin |
n |
|
chaining hash getMax |
n |
|
Suppose a graph has no edges. What is the asymptotic space cost of storing the graph as an adjacency list? |
v |
|
Suppose a graph has no edges. What is the asymptotic space cost of storing the graph as an adjacency matrix? |
V^2 |
|
Suppose a graph has every possible edge. What is the asymptotic space cost of storing the graph as an adjacency list? |
V^2 |
|
Suppose an undirected graph has one node A that is connected to every other node and the graphhas no other edges. What is the asymptotic space cost of storing the graph as an adjacency list? |
V |
|
Suppose an undirected graph has one node A that is connected to every other node and the graph has no other edges. What is the asymptotic space cost of storing the graph as an adjacency matrix? |
V^2 |
|
Suppose a graph has every possible edge. What is the asymptotic space cost of storing the graph as an adjacency matrix? |
V^2 |
|
Is an adjacency list faster or slower than an adjacency matrix for answering queries of the form,“is edge (u, v) in the graph”? |
slower |
|
Is an adjacency list faster or slower than an adjacency matrix for answering queries of the form,“are there any directed edges with u as the source node”? |
faster |
|
insertion sort |
void insertionSort(int [] array) { for(int i=1; i < array.length; i++) { int tmp = array[i]; int j; for(j=i; j > 0 && tmp < array[j-1]; j--) array[j] = array[j-1]; array[j] = tmp } }; |
|
What is the worst-case asymptotic running time of heap-sort? |
n log n |
|
What is the worst-case asymptotic running time of merge-sort? |
n log n |
|
What is the worst-case asymptotic running time of quick-sort? |
n^2 |
|
Can heap-sort be done in-place? |
yes |
|
Can merge-sort be done in-place? |
no |
|
Can quick-sort be done in-place? |
yes |
|
Consider one item in an array that is sorted with mergesort. In asymptotic (big-Oh) terms, howmany times can that one item move to a different location? |
log n |
|
What is the asymptotic running time of quick-sort if the array is already sorted (or almost sorted)and the pivot-selection strategy picks the leftmost element in the range-to-be-sorted? |
n^2 |
|
What is the asymptotic running time of quick-sort if the array is already sorted (or almost sorted)and the pivot-selection strategy picks the rightmost element in the range-to-be-sorted? |
n^2 |
|
What is the asymptotic running time of quick-sort if the array is already sorted (or almost sorted)and the pivot-selection strategy picks the middle element in the range-to-be-sorted? |
n log n |
|
Before starting a comparison sort for an array with n elements, how many possible orders arethere for the elements in the final result? |
n! |
|
If at some point during a comparison sort, the algorithm has enough information to narrow thefinal result down to k possibilities, what is the least number of possibilities that remain afterperforming an additional comparison? |
k/2 |
|
insertion sort worst case |
n^2 |
|
selection sort worst case |
n^2 |
|
heap sort worst case |
n log n |
|
merge sort worst case |
n log n |
|
quick sort avg worst case |
n log n |
|
bubble sort worst case |
n^2 |
|
quicksort |
1. pick pivot 2 partition data into 3 with pivot in middle 3 recursivley sort a,c result a,pivot,c |
|
bucket sort |
count bucket |
|
radix sort |
sort by each number place each iteration |
|
bubble, insertion, selection sorts are good for |
below a cutoff |
|
Bin Tree max # leaves |
2^h |
|
max # nodes |
2^(n+1) -1 |
|
mix # leaves |
1 |
|
deletion bin tree |
move minmum from right or move maximum from left |
|
BuildTree sorted worst case |
n log n
|
|
balance factor |
left and right subtree should have a height difference of 1 |
|
double rotation |
1 rotate problematic into parent position 2 parent becomes the other child |
|
AVLbuildTree worst case |
n log n |
|
load factor |
n / table size |
|
union find uses |
connecnted components parition an image my connected pixels of similiar color type inference |
|
union worst case |
1 |
|
find worst faces |
log n |
|
sorted cicular array insert w.c |
log n |
|
sorted circular array deleteMin w.c. |
1 |
|
heap structure |
like bst except parent not as important |
|
delete min heap basic idea |
move right most and perculate down (n) |
|
insert heap basic idea |
insert right most and perculate up (logn) |
|
dense graph |
e theta (v^2) |
|
sparse graph |
O(V) |
|
minimum spanning tree |
connected graph |
|
topological sort |
mark in degree then out put when in degree equals 0 |
|
kruskal |
1. Sort edges by weight (better: put in min-heap)2. Put each node in its own subset (of a UNION-FIND instance).3. While output size < |V|-1 – Consider next smallest edge (u,v)– if find(u) and find(v) indicate u and v are in different sets output (u,v) Perform union(find(u),find(v)) e log e |
|
hamiltonian cycle |
there is a cycle that visits all nodes exactly once |
|
SAT |
all satifiable cicuits c |
|
dfs |
pre order traversal |
|
bfs |
"level order traversal" |
|
shortest distance on network |
udirected weighted djsktras |
|
creates smallest driect weighted network |
directed weighted mst |
|
level spread |
undirected , unweighted , bfs |