A Simple Near-Linear Pseudopolynomial Time Randomized Algorithm for - - PowerPoint PPT Presentation

a simple near linear pseudopolynomial time randomized
SMART_READER_LITE
LIVE PREVIEW

A Simple Near-Linear Pseudopolynomial Time Randomized Algorithm for - - PowerPoint PPT Presentation

A Simple Near-Linear Pseudopolynomial Time Randomized Algorithm for Subset Sum Ce Jin , Hongxun Wu Tsinghua University SOSA 2019 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


slide-1
SLIDE 1

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A Simple Near-Linear Pseudopolynomial Time Randomized Algorithm for Subset Sum

Ce Jin, Hongxun Wu

Tsinghua University

SOSA 2019

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 1 / 15

slide-2
SLIDE 2

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Subset Sum

Subset Sum

Given a (multi)set S of n positive integers and a target integer t, does there exist a subset R ⊆ S that sums to exactly t?

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 2 / 15

slide-3
SLIDE 3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Subset Sum

Subset Sum

Given a (multi)set S of n positive integers and a target integer t, does there exist a subset R ⊆ S that sums to exactly t? Example: S = {1, 1, 3, 10}, t = 12

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 2 / 15

slide-4
SLIDE 4

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Subset Sum

Subset Sum

Given a (multi)set S of n positive integers and a target integer t, does there exist a subset R ⊆ S that sums to exactly t? Example: S = {1, 1, 3, 10}, t = 12 YES! R = {1, 1, 10}, sum(R) = 1 + 1 + 10 = 12

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 2 / 15

slide-5
SLIDE 5

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Subset Sum

Subset Sum

Given a (multi)set S of n positive integers and a target integer t, does there exist a subset R ⊆ S that sums to exactly t? Example: S = {1, 1, 3, 10}, t = 12 YES! R = {1, 1, 10}, sum(R) = 1 + 1 + 10 = 12 A classic NP-hard problem. O(2n/2) algorithm [Horowitz and Sahni, JACM 1974]

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 2 / 15

slide-6
SLIDE 6

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

Pseudopolynomial time algorithm: in poly(n, t) time.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 3 / 15

slide-7
SLIDE 7

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

Pseudopolynomial time algorithm: in poly(n, t) time. Dynamic programming algorithm [Bellman, 1957]: (S = {s1, . . . , sn}) f [i, x] := f [i − 1, x] OR f [i − 1, x − si] f [0, x] := [x == 0] Output f [n, t]

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 3 / 15

slide-8
SLIDE 8

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

Pseudopolynomial time algorithm: in poly(n, t) time. Dynamic programming algorithm [Bellman, 1957]: (S = {s1, . . . , sn}) f [i, x] := f [i − 1, x] OR f [i − 1, x − si] f [0, x] := [x == 0] Output f [n, t] O(nt) time

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 3 / 15

slide-9
SLIDE 9

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

O(nt) [Bellman, 1957]

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 4 / 15

slide-10
SLIDE 10

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

O(nt) [Bellman, 1957] ˜ O(n + √nt) deterministic algorithm. [Koiliaris and Xu, SODA 2017]

( ˜ O(T) stands for O(Tpoly log T))

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 4 / 15

slide-11
SLIDE 11

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

O(nt) [Bellman, 1957] ˜ O(n + √nt) deterministic algorithm. [Koiliaris and Xu, SODA 2017]

( ˜ O(T) stands for O(Tpoly log T))

˜ O(n + t) randomized algorithm. [Bringmann, SODA 2017]

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 4 / 15

slide-12
SLIDE 12

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

O(nt) [Bellman, 1957] ˜ O(n + √nt) deterministic algorithm. [Koiliaris and Xu, SODA 2017]

( ˜ O(T) stands for O(Tpoly log T))

˜ O(n + t) randomized algorithm. [Bringmann, SODA 2017]

▶ more precisely, O(n + t log t log4 n) time (failure probability 1

n)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 4 / 15

slide-13
SLIDE 13

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

O(nt) [Bellman, 1957] ˜ O(n + √nt) deterministic algorithm. [Koiliaris and Xu, SODA 2017]

( ˜ O(T) stands for O(Tpoly log T))

˜ O(n + t) randomized algorithm. [Bringmann, SODA 2017]

▶ more precisely, O(n + t log t log4 n) time (failure probability 1

n)

▶ uses color coding, layer splitting, FFT Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 4 / 15

slide-14
SLIDE 14

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

O(nt) [Bellman, 1957] ˜ O(n + √nt) deterministic algorithm. [Koiliaris and Xu, SODA 2017]

( ˜ O(T) stands for O(Tpoly log T))

˜ O(n + t) randomized algorithm. [Bringmann, SODA 2017]

▶ more precisely, O(n + t log t log4 n) time (failure probability 1

n)

▶ uses color coding, layer splitting, FFT Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 4 / 15

slide-15
SLIDE 15

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Pseudopolynomial time algorithm

O(nt) [Bellman, 1957] ˜ O(n + √nt) deterministic algorithm. [Koiliaris and Xu, SODA 2017]

( ˜ O(T) stands for O(Tpoly log T))

˜ O(n + t) randomized algorithm. [Bringmann, SODA 2017]

▶ more precisely, O(n + t log t log4 n) time (failure probability 1

n)

▶ uses color coding, layer splitting, FFT

Near-optimal! (No t1−ε2o(n) time algorithm for any ε > 0, unless SETH fails) [Abboud, Bringmann, Hermelin, Shabtay, SODA 2019]

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 4 / 15

slide-16
SLIDE 16

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our result

We present a randomized algorithm for Subset Sum in ˜ O(n + t) time.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 5 / 15

slide-17
SLIDE 17

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our result

We present a randomized algorithm for Subset Sum in ˜ O(n + t) time. Our techniques are simple and quite different from Bringmann’s algorithm. generating functions FFT

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 5 / 15

slide-18
SLIDE 18

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our result

We present a randomized algorithm for Subset Sum in ˜ O(n + t) time. Our techniques are simple and quite different from Bringmann’s algorithm. generating functions FFT Precise running time (with failure probability

1 n+t ) is O(n + t log2 t).

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 5 / 15

slide-19
SLIDE 19

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our result

We present a randomized algorithm for Subset Sum in ˜ O(n + t) time. Our techniques are simple and quite different from Bringmann’s algorithm. generating functions FFT Precise running time (with failure probability

1 n+t ) is O(n + t log2 t).

Can be improved to O(n + t log t) time (slightly less simple). faster than Bringmann’s algorithm by a log4 n factor

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 5 / 15

slide-20
SLIDE 20

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our result

We present a randomized algorithm for Subset Sum in ˜ O(n + t) time. Our techniques are simple and quite different from Bringmann’s algorithm. generating functions FFT Precise running time (with failure probability

1 n+t ) is O(n + t log2 t).

Can be improved to O(n + t log t) time (slightly less simple). faster than Bringmann’s algorithm by a log4 n factor

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 5 / 15

slide-21
SLIDE 21

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

(S = {s1, s2, . . . , sn}, target integer = t) Consider the generating function of this instance A(x) = ∏

1≤i≤n

(1 + xsi)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 6 / 15

slide-22
SLIDE 22

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

(S = {s1, s2, . . . , sn}, target integer = t) Consider the generating function of this instance A(x) = ∏

1≤i≤n

(1 + xsi) Expand it A(x) = 1 + ∑

i≥1

aixi

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 6 / 15

slide-23
SLIDE 23

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

(S = {s1, s2, . . . , sn}, target integer = t) Consider the generating function of this instance A(x) = ∏

1≤i≤n

(1 + xsi) Expand it A(x) = 1 + ∑

i≥1

aixi ai = number of subsets summing to i Output YES if at ̸= 0

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 6 / 15

slide-24
SLIDE 24

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

(S = {s1, s2, . . . , sn}, target integer = t) Consider the generating function of this instance A(x) = ∏

1≤i≤n

(1 + xsi) Expand it A(x) = 1 + ∑

i≥1

aixi ai = number of subsets summing to i Output YES if at ̸= 0 Example: S = {1, 2, 3}, t = 3 A(x) = (1 + x1)(1 + x2)(1 + x3) = 1 + x + x2 + 2x3 + x4 + x5 + x6 2x3: {1, 2}, {3}

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 6 / 15

slide-25
SLIDE 25

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . Goal: efficiently compute A(x) mod xt+1

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 7 / 15

slide-26
SLIDE 26

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . Goal: efficiently compute A(x) mod xt+1 Straightforwardly expanding needs O(nt) arithmetic operations Need a smarter way to do this

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 7 / 15

slide-27
SLIDE 27

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . Goal: efficiently compute A(x) mod xt+1 Straightforwardly expanding needs O(nt) arithmetic operations Need a smarter way to do this The coefficients are too large (∼ 2n)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 7 / 15

slide-28
SLIDE 28

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . Goal: efficiently compute A(x) mod xt+1 Straightforwardly expanding needs O(nt) arithmetic operations Need a smarter way to do this The coefficients are too large (∼ 2n) Work in finite field Fp for some Θ(log t)-bit prime p. Assume an arithmetic operation takes constant time.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 7 / 15

slide-29
SLIDE 29

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Our approach: generating functions

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . Goal: efficiently compute A(x) mod xt+1 Straightforwardly expanding needs O(nt) arithmetic operations Need a smarter way to do this The coefficients are too large (∼ 2n) Work in finite field Fp for some Θ(log t)-bit prime p. Assume an arithmetic operation takes constant time.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 7 / 15

slide-30
SLIDE 30

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing (ln A(x)) mod xt+1

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 8 / 15

slide-31
SLIDE 31

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing (ln A(x)) mod xt+1

Natural logarithm as a series

ln(1 + x) := x − x2 2 + x3 3 − · · · + (−1)k−1xk k + · · ·

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 8 / 15

slide-32
SLIDE 32

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing (ln A(x)) mod xt+1

Natural logarithm as a series

ln(1 + x) := x − x2 2 + x3 3 − · · · + (−1)k−1xk k + · · · ln A(x) = ln ∏

1≤i≤n

(1 + xsi)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 8 / 15

slide-33
SLIDE 33

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing (ln A(x)) mod xt+1

Natural logarithm as a series

ln(1 + x) := x − x2 2 + x3 3 − · · · + (−1)k−1xk k + · · · ln A(x) = ln ∏

1≤i≤n

(1 + xsi) = ∑

1≤i≤n

ln(1 + xsi)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 8 / 15

slide-34
SLIDE 34

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing (ln A(x)) mod xt+1

Natural logarithm as a series

ln(1 + x) := x − x2 2 + x3 3 − · · · + (−1)k−1xk k + · · · ln A(x) = ln ∏

1≤i≤n

(1 + xsi) = ∑

1≤i≤n

ln(1 + xsi) = ∑

1≤j≤t

mj ln(1 + xj) (mj denotes the number of i’s with si = j)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 8 / 15

slide-35
SLIDE 35

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing (ln A(x)) mod xt+1

Natural logarithm as a series

ln(1 + x) := x − x2 2 + x3 3 − · · · + (−1)k−1xk k + · · · ln A(x) = ln ∏

1≤i≤n

(1 + xsi) = ∑

1≤i≤n

ln(1 + xsi) = ∑

1≤j≤t

mj ln(1 + xj) (mj denotes the number of i’s with si = j) = ∑

1≤j≤t

mj ∑

k≥1

(−1)k−1xjk k

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 8 / 15

slide-36
SLIDE 36

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing (ln A(x)) mod xt+1

Natural logarithm as a series

ln(1 + x) := x − x2 2 + x3 3 − · · · + (−1)k−1xk k + · · · ln A(x) = ln ∏

1≤i≤n

(1 + xsi) = ∑

1≤i≤n

ln(1 + xsi) = ∑

1≤j≤t

mj ln(1 + xj) (mj denotes the number of i’s with si = j) = ∑

1≤j≤t

mj ∑

k≥1

(−1)k−1xjk k (ln A(x)) mod xt+1 only has ∑

1≤j≤t⌊t/j⌋ = O(t log t) nonzero terms!

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 8 / 15

slide-37
SLIDE 37

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing A(x) (mod xt+1)

We can compute B(x) := (ln A(x)) mod xt+1 in O(t log t) time. Next: Recover A(x) mod xt+1 by computing exp(B(x)) mod xt+1.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 9 / 15

slide-38
SLIDE 38

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Given coefficients of B(x), we can compute exp(B(x)) mod xt+1 in O(M(t)) time, where M(t) denotes the running time of multiplying two polynomials of degree t. [Brent, 1976] FFT: M(t) = O(t log t)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 10 / 15

slide-39
SLIDE 39

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Given coefficients of B(x), we can compute exp(B(x)) mod xt+1 in O(M(t)) time, where M(t) denotes the running time of multiplying two polynomials of degree t. [Brent, 1976] FFT: M(t) = O(t log t) uses Newton’s iteration method

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 10 / 15

slide-40
SLIDE 40

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Given coefficients of B(x), we can compute exp(B(x)) mod xt+1 in O(M(t)) time, where M(t) denotes the running time of multiplying two polynomials of degree t. [Brent, 1976] FFT: M(t) = O(t log t) uses Newton’s iteration method

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 10 / 15

slide-41
SLIDE 41

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Given coefficients of B(x), we can compute exp(B(x)) mod xt+1 in O(M(t)) time, where M(t) denotes the running time of multiplying two polynomials of degree t. [Brent, 1976] FFT: M(t) = O(t log t) uses Newton’s iteration method Here we describe a slightly simpler (and slower) folklore algorithm in O(M(t) log t) = O(t log2 t) time.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 10 / 15

slide-42
SLIDE 42

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Let C(x) := exp(B(x)) = ∑

i≥0 cixi.

(c0 = 1)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 11 / 15

slide-43
SLIDE 43

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Let C(x) := exp(B(x)) = ∑

i≥0 cixi.

(c0 = 1) C ′(x) = ( exp(B(x)) )′ = exp(B(x))B′(x) = C(x)B′(x)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 11 / 15

slide-44
SLIDE 44

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Let C(x) := exp(B(x)) = ∑

i≥0 cixi.

(c0 = 1) C ′(x) = ( exp(B(x)) )′ = exp(B(x))B′(x) = C(x)B′(x) Let B′(x) = ∑

i≥0 bixi. Comparing xi−1 term gives a recurrence relation,

ci = 1 i

i−1

j=0

cjbi−1−j

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 11 / 15

slide-45
SLIDE 45

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Computing exp(B(x)) mod xt+1

Let C(x) := exp(B(x)) = ∑

i≥0 cixi.

(c0 = 1) C ′(x) = ( exp(B(x)) )′ = exp(B(x))B′(x) = C(x)B′(x) Let B′(x) = ∑

i≥0 bixi. Comparing xi−1 term gives a recurrence relation,

ci = 1 i

i−1

j=0

cjbi−1−j b0, b1, . . . , bt−1 are known. Want to compute c1, c2, . . . , ct.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 11 / 15

slide-46
SLIDE 46

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Divide and Conquer

ci = 1 i

i−1

j=0

cjbi−1−j Initialize c0 = 1, ci ← 0(1 ≤ i ≤ t). Call Compute(0, t). procedure Compute(L, R) if L < R then M ← ⌊ L+R

2 ⌋

Compute(L, M) ▷ Now cj(0 ≤ j ≤ M) are finalized for i ← M + 1, M + 2, . . . , R do ci ← ci + 1 i

M

j=L

cjbi−1−j Compute(M + 1, R)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 12 / 15

slide-47
SLIDE 47

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Divide and Conquer

ci = 1 i

i−1

j=0

cjbi−1−j Initialize c0 = 1, ci ← 0(1 ≤ i ≤ t). Call Compute(0, t). procedure Compute(L, R) if L < R then M ← ⌊ L+R

2 ⌋

Compute(L, M) ▷ Now cj(0 ≤ j ≤ M) are finalized for i ← M + 1, M + 2, . . . , R do ci ← ci + 1 i

M

j=L

cjbi−1−j ▷ 0 ≤ i − 1 − j ≤ R − 1 − L Compute(M + 1, R)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 12 / 15

slide-48
SLIDE 48

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Divide and Conquer

ci = 1 i

i−1

j=0

cjbi−1−j Initialize c0 = 1, ci ← 0(1 ≤ i ≤ t). Call Compute(0, t). procedure Compute(L, R) if L < R then M ← ⌊ L+R

2 ⌋

Compute(L, M) ▷ Now cj(0 ≤ j ≤ M) are finalized for i ← M + 1, M + 2, . . . , R do ci ← ci + 1 i

M

j=L

cjbi−1−j ▷ 0 ≤ i − 1 − j ≤ R − 1 − L Compute(M + 1, R) Use FFT: O((R − L) log(R − L)) time! Total time: T(t) = 2T(t/2) + O(t log t) = O(t log2 t)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 12 / 15

slide-49
SLIDE 49

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Working in finite field Fp

To avoid large coefficients, we choose a prime p and do all arithmetic

  • perations mod p.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 13 / 15

slide-50
SLIDE 50

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Working in finite field Fp

To avoid large coefficients, we choose a prime p and do all arithmetic

  • perations mod p.

A fraction x/y becomes (x · y−1) mod p, where y−1 denotes the multiplicative inverse of y mod p (can be found using (Extended) Euclid’s algorithm)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 13 / 15

slide-51
SLIDE 51

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Working in finite field Fp

To avoid large coefficients, we choose a prime p and do all arithmetic

  • perations mod p.

A fraction x/y becomes (x · y−1) mod p, where y−1 denotes the multiplicative inverse of y mod p (can be found using (Extended) Euclid’s algorithm) Requirement: y ̸≡ 0 (mod p)

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 13 / 15

slide-52
SLIDE 52

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Working in finite field Fp

To avoid large coefficients, we choose a prime p and do all arithmetic

  • perations mod p.

A fraction x/y becomes (x · y−1) mod p, where y−1 denotes the multiplicative inverse of y mod p (can be found using (Extended) Euclid’s algorithm) Requirement: y ̸≡ 0 (mod p) Our fractions only have denominators from {1, 2, . . . , t}. It’s sufficient to choose p > t.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 13 / 15

slide-53
SLIDE 53

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . For prime p > t, we can compute (ai mod p) for all 1 ≤ i ≤ t in ˜ O(n + t) time.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 14 / 15

slide-54
SLIDE 54

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . For prime p > t, we can compute (ai mod p) for all 1 ≤ i ≤ t in ˜ O(n + t) time. Output YES when (at mod p) ̸= 0.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 14 / 15

slide-55
SLIDE 55

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . For prime p > t, we can compute (ai mod p) for all 1 ≤ i ≤ t in ˜ O(n + t) time. Output YES when (at mod p) ̸= 0. Will make a mistake if p divides at.

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 14 / 15

slide-56
SLIDE 56

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A(x) = ∏

1≤i≤n

(1 + xsi) = 1 + a1x + a2x2 + · · · + atxt + . . . For prime p > t, we can compute (ai mod p) for all 1 ≤ i ≤ t in ˜ O(n + t) time. Output YES when (at mod p) ̸= 0. Will make a mistake if p divides at. at ≤ 2n, so at has at most n prime factors. Randomly picking a prime from interval [t + 1, (n + t)3] makes failure probability less than

1 n+t .

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 14 / 15

slide-57
SLIDE 57

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Closing remarks

Open problem: Can we achieve deterministic near-linear time for Subset Sum? (current best: ˜ O(n + √nt) by Koiliaris and Xu [SODA 2017])

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 15 / 15

slide-58
SLIDE 58

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Closing remarks

Open problem: Can we achieve deterministic near-linear time for Subset Sum? (current best: ˜ O(n + √nt) by Koiliaris and Xu [SODA 2017]) Does our technique apply to other problems?

Thank you!

Ce Jin, Hongxun Wu (Tsinghua University) SOSA 2019 15 / 15