week 11: applications, randomized algorithms · 2015. 11. 16. · the probabilistic method joshua...
TRANSCRIPT
The Probabilistic Method
Joshua BrodyCS49/Math59
Fall 2015
Week 11: Applications, Randomized Algorithms
Reading Quiz
(A) runtime
(B) amount of randomness used
(C) amount of memory used
(D) tightness of approximation factor
(E) none of the above
What resource is most important to optimize in streaming algorithms?
Reading Quiz
(A) runtime
(B) amount of randomness used
(C) amount of memory used
(D) tightness of approximation factor
(E) none of the above
What resource is most important to optimize in streaming algorithms?
Error-Correcting Codes
10011
[Shannon 48]
ECC: set C ⊆ {0,1}n, bijection ENC: {0,1}k → C• rate R := k/n• distance: min HD(c1,c2)
Error-Correcting Codes
0001010101
10011
[Shannon 48]
ECC: set C ⊆ {0,1}n, bijection ENC: {0,1}k → C• rate R := k/n• distance: min HD(c1,c2)
Error-Correcting Codes
0100110100
10011
[Shannon 48]
ECC: set C ⊆ {0,1}n, bijection ENC: {0,1}k → C• rate R := k/n• distance: min HD(c1,c2)
Error-Correcting Codes
0100110100
10011 10011
[Shannon 48]
ECC: set C ⊆ {0,1}n, bijection ENC: {0,1}k → C• rate R := k/n• distance: min HD(c1,c2)
Errors in ECCs
0001010 0100110
10011 10011
• each bit flipped w/probability p• p-fraction of bits flipped•random fraction of bits flipped •adversarially chosen fraction of bits flipped
•bits erased w/probability p•bits transposed w/probability p...
Adjacency Matrix of Magic Graphs
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
Adjacency Matrix of Magic Graphs
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
columns indexed by vertices in L
rows indexed by vertices in R
Adjacency Matrix of Magic Graphs
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
columns indexed by vertices in L
rows indexed by vertices in R
aij = 1 iff (vj, ri) is edge in magic graph
Magic GraphMatrix Multiplication
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
x1
x2
x3
x4
x5
x6
x7
x8
=*
y1
y2
y3
y4
y5
y6
Magic GraphMatrix Multiplication
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
x1
x2
x3
x4
x5
x6
x7
x8
=*
y1
y2
y3
y4
y5
y6
yi = ∑ aik * xkk
Magic GraphMatrix Multiplication
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
x1
x2
x3
x4
x5
x6
x7
x8
=*
y1
y2
y3
y4
y5
y6
Magic GraphMatrix Multiplication
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
x1
x2
x3
x4
x5
x6
x7
x8
=*
y1
y2
y3
y4
y5
y6
xj = 1 iff j ∈ S
Magic GraphMatrix Multiplication
a11 a12 a13 a14 a15 a16 a17 a18
a21 a22 a23 a24 a25 a26 a27 a28
a31 a32 a33 a34 a35 a36 a37 a38
a41 a42 a43 a44 a45 a46 a47 a48
a51 a52 a53 a54 a55 a56 a57 a58
a61 a62 a63 a64 a65 a66 a67 a68
x1
x2
x3
x4
x5
x6
x7
x8
=*
y1
y2
y3
y4
y5
y6
yi = ∑ aik * xk
= ∑ aik
kxj = 1 iff j ∈ Sk ∈ S
quickSort
Algorithm quickSort(A, left, right):Input: array of integers A, indices left,right Output: nothing, but A[left...right] sorted.
if(right > left) {p = partition(A, left, right)quickSort(A, left, p-1)quickSort(A, p+1, right)
}Return;
}
quickSort
Algorithm partition(A, start, end):Input: array of integers A, range start, end Output: location of pivot element,
subrange A[left...right] partitioned.pivot = A[end]left=start; right=end-1;while(right > left) {if(A[left]>=pivot) { left++; }if(A[right] < pivot) { right--; }swap(A,left,right)
}swap(A,left,end)
}
Quicksort
1 4 6 17 1 2 15 4 13 3 9
3 4 6 8 1 2 17 13 12 15
6 8 3 41 13 12
6 83
17
13
8
12
Randomized Quicksort
The Probabilistic Method