Recurrence Relations Flashcards

1
Q

QuickSort

A

QS(n) = QS(s-left) + QS(right - s) + O(n), n = right - left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

partitioning around a pivot

A

O(nlogn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

QuickSort best case

A

theta (nlogn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

QuickSort worst case

A

theta (n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

QuickSort average case

A

theta (nlogn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

QuickSelect average case

A

C(n) = C(n/2) + (n+1)
theta (n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

QuickSelect worst case

A

theta (n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Closest Pairs
sorting: O(nlogn)
splitting: T(n/2)

A

T(n) = 2T(n/2) + O(nlogn)
T(n) = O(n (logn)^2 )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

BFS running time

A

O(n)
or O(edges + nodes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

DFS running time

A

O(n) or O(edges + nodes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Topological Sort

A

O (n)
O (m+n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Heap operations

A

Insert: O (log n)
extract min: O (log n)
find min: O (1)
heapify O(n)
delete: O( log n )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Heapsort

A

O(nlogn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Dijkstra’s

A

O (edge + vertices*log (vertices) )
runtime: 0 (#edges * #vertices)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

max weight independent set

A

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}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

weighted path

A

totCost(i, j) = max {totCost (i - 1, j), totCost (i, j - 1)} + Cij

17
Q

knapsack

A

V (n, w) = max { V ( n-1, w ), V ( n - 1, W - Wn ) + Vn }

18
Q

long increasing subsequence in 1d array

A

F (k) = max (i < k) and (xi < xk) { F (i) } + 1

19
Q

longest common subsequence

A

if s1i = s2i: LCS ( i, j ) = LCS ( i - 1, j - 1 ) + 1
if s1i NOT = s2i: LCS ( i, j ) = max { LCS ( i - 1, j ) , LCS ( i, j - 1) }

20
Q

optimal binary search tree

A

C [i, j] = min {C [i, k + 1], C [k + 1, j]} + sum of probabilities up to j (pic in text chain)