Recurrence Relations Flashcards
QuickSort
QS(n) = QS(s-left) + QS(right - s) + O(n), n = right - left
partitioning around a pivot
O(nlogn)
QuickSort best case
theta (nlogn)
QuickSort worst case
theta (n^2)
QuickSort average case
theta (nlogn)
QuickSelect average case
C(n) = C(n/2) + (n+1)
theta (n)
QuickSelect worst case
theta (n^2)
Closest Pairs
sorting: O(nlogn)
splitting: T(n/2)
T(n) = 2T(n/2) + O(nlogn)
T(n) = O(n (logn)^2 )
BFS running time
O(n)
or O(edges + nodes)
DFS running time
O(n) or O(edges + nodes)
Topological Sort
O (n)
O (m+n)
Heap operations
Insert: O (log n)
extract min: O (log n)
find min: O (1)
heapify O(n)
delete: O( log n )
Heapsort
O(nlogn)
Dijkstra’s
O (edge + vertices*log (vertices) )
runtime: 0 (#edges * #vertices)
max weight independent set
maxVal(i) = max {maxVal(i - 1), maxVal(i-2) + Ci}
for gap of 2: max {maxVal(i - 1), maxVal(i - 2), maxVal(i - 3) + Ci}