Advanced Algorithms (I) Shanghai Jiao Tong University Chihao Zhang - - PowerPoint PPT Presentation

advanced algorithms i
SMART_READER_LITE
LIVE PREVIEW

Advanced Algorithms (I) Shanghai Jiao Tong University Chihao Zhang - - PowerPoint PPT Presentation

Advanced Algorithms (I) Shanghai Jiao Tong University Chihao Zhang March 2nd, 2020 Information Instructor: (chihao@sjtu.edu.cn) TA: (yangfl@sjtu.edu.cn) Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Office Hour: via


slide-1
SLIDE 1

Shanghai Jiao Tong University

Chihao Zhang

Advanced Algorithms (I)

March 2nd, 2020

slide-2
SLIDE 2

Information

Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn) TA: 杨凤麟 (yangfl@sjtu.edu.cn) Office Hour: via Canvas or WeChat Group

slide-3
SLIDE 3

References

Probability and Computing Randomized Algorithms The Probabilistic Method

  • M. Mitzenmacher & E. Upfal
  • R. Motwani & P

. Raghavan

  • N. Alon & J. Spencer
slide-4
SLIDE 4

Polynomial Identity Testing

slide-5
SLIDE 5

Polynomial Identity Testing

Given two polynomials and

F(x) =

d

i=1

(x − ai) G(x) =

d

i=0

bixi

slide-6
SLIDE 6

Polynomial Identity Testing

Given two polynomials and

F(x) =

d

i=1

(x − ai) G(x) =

d

i=0

bixi

Is F(x) ≡ G(x)?

slide-7
SLIDE 7

Polynomial Identity Testing

Given two polynomials and

F(x) =

d

i=1

(x − ai) G(x) =

d

i=0

bixi

Is F(x) ≡ G(x)?

  • Example. F(x) = (x − 1)(x − 2)(x + 3); G(x) = x3 − 7x + 6
slide-8
SLIDE 8
slide-9
SLIDE 9

One can expand and compare the coefficients…

F(x)

slide-10
SLIDE 10

One can expand and compare the coefficients…

F(x)

It takes arithmetic operations.

O(d2)

slide-11
SLIDE 11

One can expand and compare the coefficients…

F(x)

It takes arithmetic operations.

O(d2)

Can be improved to using FFT.

O(d log d)

slide-12
SLIDE 12

One can expand and compare the coefficients…

F(x)

It takes arithmetic operations.

O(d2)

Can be improved to using FFT.

O(d log d)

If random coins are allowed…

slide-13
SLIDE 13

One can expand and compare the coefficients…

F(x)

It takes arithmetic operations.

O(d2)

Can be improved to using FFT.

O(d log d)

If random coins are allowed…

  • The problem can be solved much faster
slide-14
SLIDE 14

One can expand and compare the coefficients…

F(x)

It takes arithmetic operations.

O(d2)

Can be improved to using FFT.

O(d log d)

If random coins are allowed…

  • The problem can be solved much faster
  • at the cost of making error.
slide-15
SLIDE 15
slide-16
SLIDE 16

Choosing a uniform number s ∈ {1,2,…,100d}

slide-17
SLIDE 17

Choosing a uniform number s ∈ {1,2,…,100d} Test whether F(s) = G(s)

slide-18
SLIDE 18

Choosing a uniform number s ∈ {1,2,…,100d} Test whether F(s) = G(s)

  • If

, then it always holds that

F(x) ≡ G(x) F(s) = G(s)

slide-19
SLIDE 19

Choosing a uniform number s ∈ {1,2,…,100d} Test whether F(s) = G(s)

  • If

, then it always holds that

F(x) ≡ G(x) F(s) = G(s)

  • If

, how likely is that ?

F(x) ≢ G(x) F(s) ≠ G(s)

slide-20
SLIDE 20

Choosing a uniform number s ∈ {1,2,…,100d} Test whether F(s) = G(s)

  • If

, then it always holds that

F(x) ≡ G(x) F(s) = G(s)

  • If

, how likely is that ?

F(x) ≢ G(x) F(s) ≠ G(s)

  • Theorem. (Fundamental Theorem of Algebra)

A polynomial of degree has at most roots in

d d ℂ

slide-21
SLIDE 21
slide-22
SLIDE 22

Our algorithm outputs wrong answer only when

slide-23
SLIDE 23

Our algorithm outputs wrong answer only when

  • ; and

F(x) ≢ G(x)

slide-24
SLIDE 24

Our algorithm outputs wrong answer only when

  • ; and

F(x) ≢ G(x)

  • is a root of

s F(x) − G(x)

slide-25
SLIDE 25

Our algorithm outputs wrong answer only when

  • ; and

F(x) ≢ G(x)

  • is a root of

s F(x) − G(x)

This happens with probability at most .

1 100

slide-26
SLIDE 26

Our algorithm outputs wrong answer only when

  • ; and

F(x) ≢ G(x)

  • is a root of

s F(x) − G(x)

This happens with probability at most .

1 100

It only costs

  • perations to compute

and .

O(d) F(s) G(s)

slide-27
SLIDE 27

Our algorithm outputs wrong answer only when

  • ; and

F(x) ≢ G(x)

  • is a root of

s F(x) − G(x)

This happens with probability at most .

1 100

It only costs

  • perations to compute

and .

O(d) F(s) G(s)

One can repeat the algorithm times:

t

  • error reduces to

;

100−t

  • cost increases to

.

O(td)

slide-28
SLIDE 28

Multi-variable Polynomials

slide-29
SLIDE 29

Multi-variable Polynomials

The idea applies to a more general setting.

slide-30
SLIDE 30

Multi-variable Polynomials

The idea applies to a more general setting. Let for some field ,

F, G ∈ 𝔾(x1, …, xn) 𝔾

slide-31
SLIDE 31

Multi-variable Polynomials

The idea applies to a more general setting. Let for some field ,

F, G ∈ 𝔾(x1, …, xn) 𝔾

Is F(x1, …, xn) ≡ G(x1, …, xn)?

slide-32
SLIDE 32
  • Theorem. (Schwartz-Zippel Theorem)

Let be a non-zero multivariate polynomial of degree at most . For any set , it holds that

Q ∈ 𝔾[x1, …, xn] d U ⊆ 𝔾 Pr

r1,…,rn∈RU[Q(r1, …, rn) = 0] ≤

d |U|

slide-33
SLIDE 33

Proof of Schwartz-Zippel

slide-34
SLIDE 34

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem

  • f Algebra.

n n = 1

slide-35
SLIDE 35

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem

  • f Algebra.

n n = 1

Assuming it holds for smaller …

n

slide-36
SLIDE 36

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem

  • f Algebra.

n n = 1

Assuming it holds for smaller …

n

Q(x1, …, xn) =

k

i=0

xi

1 ⋅ Qi(x2, …, xn)

slide-37
SLIDE 37

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem

  • f Algebra.

n n = 1

Assuming it holds for smaller …

n

Q(x1, …, xn) =

k

i=0

xi

1 ⋅ Qi(x2, …, xn)

Pr [Q = 0] ≤ Pr [Qk = 0] + Pr [Q = 0|Qk ≠ 0] ≤ d − k |U| + k |U|

slide-38
SLIDE 38
slide-39
SLIDE 39

Our randomized algorithm generalizes to the multi- variable setting by Schwartz-Zippel theorem.

slide-40
SLIDE 40

Our randomized algorithm generalizes to the multi- variable setting by Schwartz-Zippel theorem. If the polynomials are given in product form, one scan of and is sufficient to evaluate them.

F G

slide-41
SLIDE 41

Our randomized algorithm generalizes to the multi- variable setting by Schwartz-Zippel theorem. If the polynomials are given in product form, one scan of and is sufficient to evaluate them.

F G

Linear time algorithm with at most error!

1 %

slide-42
SLIDE 42

Our randomized algorithm generalizes to the multi- variable setting by Schwartz-Zippel theorem. If the polynomials are given in product form, one scan of and is sufficient to evaluate them.

F G

Linear time algorithm with at most error!

1 %

It is a wide open problem in the complexity theory that whether this can be done in deterministic polynomial time.

slide-43
SLIDE 43

Some Complexity Theory

slide-44
SLIDE 44

Some Complexity Theory

Problems solvable in deterministic polynomial-time:

P

slide-45
SLIDE 45

Some Complexity Theory

Problems solvable in deterministic polynomial-time:

P

Problems solvable in randomized polynomial-time: BPP

slide-46
SLIDE 46

Some Complexity Theory

Problems solvable in deterministic polynomial-time:

P

Problems solvable in randomized polynomial-time: BPP

Is ?

BPP = P

slide-47
SLIDE 47

Min-Cut in a Graph

slide-48
SLIDE 48

Min-Cut in a Graph

A cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ E G

slide-49
SLIDE 49

Min-Cut in a Graph

A cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ E G

How to find the minimum cut?

slide-50
SLIDE 50

Min-Cut in a Graph

A cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ E G

How to find the minimum cut? It can be solved using max-flow techniques

slide-51
SLIDE 51

Min-Cut in a Graph

A cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ E G

How to find the minimum cut? It can be solved using max-flow techniques With the fastest max-flow algorithm, it takes time.

O(n × mn)

slide-52
SLIDE 52

Karger’s Min-Cut Algorithm

slide-53
SLIDE 53

Karger’s Min-Cut Algorithm

David Karger

slide-54
SLIDE 54

Karger’s Min-Cut Algorithm

David Karger

Using random bits, Karger found a much simpler algorithm

slide-55
SLIDE 55

Karger’s Min-Cut Algorithm

David Karger

Using random bits, Karger found a much simpler algorithm The only operation required is edge contraction

slide-56
SLIDE 56

Edge Contraction

slide-57
SLIDE 57

Edge Contraction

1 2 3

slide-58
SLIDE 58

Edge Contraction

1 2 3 1 2 3

slide-59
SLIDE 59

Edge Contraction

1 2 3 1 2 3

slide-60
SLIDE 60

Edge Contraction

1 2 3 1 2 3 1/2 3

slide-61
SLIDE 61

Edge Contraction

1 2 3 1 2 3 1/2 3

slide-62
SLIDE 62

Edge Contraction

1 2 3 1 2 3 1/2 3

  • no self-loop
slide-63
SLIDE 63

Edge Contraction

1 2 3 1 2 3 1/2 3

  • parallel edges may exist
  • no self-loop
slide-64
SLIDE 64

The Algorithm

slide-65
SLIDE 65

The Algorithm

Karger’s Min-cut Algorithm

  • 1. Randomly choose an edge and contract it

until only two vertices remains.

  • 2. Output remaining edges.
slide-66
SLIDE 66

Analysis

slide-67
SLIDE 67

Analysis

The algorithm contracts pair of vertices in total.

n − 2

slide-68
SLIDE 68

Analysis

The algorithm contracts pair of vertices in total.

n − 2

Fix an minimum cut , we bound the probability that it survives.

C

slide-69
SLIDE 69

Analysis

The algorithm contracts pair of vertices in total.

n − 2

Fix an minimum cut , we bound the probability that it survives.

C

Assume the removal of separates and .

C S ⊆ V ¯ S = V∖S

slide-70
SLIDE 70

Analysis

The algorithm contracts pair of vertices in total.

n − 2

Fix an minimum cut , we bound the probability that it survives.

C

Assume the removal of separates and .

C S ⊆ V ¯ S = V∖S

All contractions happen within or .

S ¯ S

slide-71
SLIDE 71
slide-72
SLIDE 72

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai i C

slide-73
SLIDE 73

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai i C

We need to bound

slide-74
SLIDE 74

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai i C

We need to bound Pr [

n−2

i=1

Ai] =

n−2

i=1

Pr Ai

i−1

j=1

Aj

slide-75
SLIDE 75

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai i C

We need to bound Pr [

n−2

i=1

Ai] =

n−2

i=1

Pr Ai

i−1

j=1

Aj We assume |C| = k

slide-76
SLIDE 76
slide-77
SLIDE 77

In -th contraction,

i

slide-78
SLIDE 78

In -th contraction,

i

  • the graph contains

vertices;

  • each vertex is of degree at least .

n − i + 1 k

slide-79
SLIDE 79

In -th contraction,

i

  • the graph contains

vertices;

  • each vertex is of degree at least .

n − i + 1 k

Therefore, conditional on that still survives,

C

slide-80
SLIDE 80

In -th contraction,

i

  • the graph contains

vertices;

  • each vertex is of degree at least .

n − i + 1 k

Therefore, conditional on that still survives,

C

Pr Ai

i−1

j=1

Aj ≥ 1 − 2k k(n − i + 1) = n − i − 1 n − i + 1

slide-81
SLIDE 81
slide-82
SLIDE 82

Therefore

slide-83
SLIDE 83

Therefore Pr [

n−2

i=1

Ai] =

n−2

i=1

Pr Ai

i−1

j=1

Aj ≥

n−2

i=1

n − i − 1 n − i + 1 = n − 2 n ⋅ n − 3 n − 1 ⋯ 1 3 = 2 n(n − 1)

slide-84
SLIDE 84
slide-85
SLIDE 85

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

slide-86
SLIDE 86

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

1 − (1 − 2 n(n − 1))

50n2

≥ 1 − e−100

slide-87
SLIDE 87

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

1 − (1 − 2 n(n − 1))

50n2

≥ 1 − e−100 How about the time cost?

slide-88
SLIDE 88

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

1 − (1 − 2 n(n − 1))

50n2

≥ 1 − e−100 How about the time cost? If we store the graph in a adjacency matrix, one needs to contract an edge…

O(n)

slide-89
SLIDE 89

Karger-Stein’s Trick

slide-90
SLIDE 90

Karger-Stein’s Trick

Recall Pr [

n−2

i=1

Ai] = n − 2 n ⋅ n − 3 n − 1 ⋯ 1 3

slide-91
SLIDE 91

Karger-Stein’s Trick

Recall Pr [

n−2

i=1

Ai] = n − 2 n ⋅ n − 3 n − 1 ⋯ 1 3 The more we contracts, the easier gets hit

C

slide-92
SLIDE 92

Karger-Stein’s Trick

Recall Pr [

n−2

i=1

Ai] = n − 2 n ⋅ n − 3 n − 1 ⋯ 1 3 The more we contracts, the easier gets hit

C

Idea: Make a copy before it becomes too bad!

slide-93
SLIDE 93

Karger-Stein’s Trick

Recall Pr [

n−2

i=1

Ai] = n − 2 n ⋅ n − 3 n − 1 ⋯ 1 3 The more we contracts, the easier gets hit

C

Idea: Make a copy before it becomes too bad! The success probability can be improved to Ω (

1 log n )