Complexity Theory of Polynomial-Time Problems Lecture 6: 3SUM Part - - PowerPoint PPT Presentation

β–Ά
complexity theory of polynomial time problems
SMART_READER_LITE
LIVE PREVIEW

Complexity Theory of Polynomial-Time Problems Lecture 6: 3SUM Part - - PowerPoint PPT Presentation

Complexity Theory of Polynomial-Time Problems Lecture 6: 3SUM Part I Karl Bringmann 3SUM given sets ,, of integers are there , , such that + + = 0 ? (we assume that we can


slide-1
SLIDE 1

Complexity Theory of Polynomial-Time Problems

Karl Bringmann

Lecture 6: 3SUM Part I

slide-2
SLIDE 2

3SUM

given sets 𝐡,𝐢,𝐷 of π‘œ integers are there 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢,𝑑 ∈ 𝐷 such that 𝑏 + 𝑐 + 𝑑 = 0? (we assume that we can add/subtract/compare input integers in constant time) trivial algorithm: 𝑃(π‘œ/) well-known: 𝑃(π‘œ1) Conjecture: no 𝑃 π‘œ123 algorithm β†’ 3SUM-Hardness

[Gajentaan,Overmars’95]

slide-3
SLIDE 3

More Known Algorithms

trivial: 𝑃(π‘œ/) well-known: 𝑃(π‘œ1) using Word RAM bit-tricks: 𝑃(π‘œ1 β‹…

789:; ; ), 𝑃(π‘œ1 β‹… (789 789 <): 789:<

) no bit-tricks: 𝑃(π‘œ1 β‹…

(789 789 <): 789 <

)

[Baran,Demaine,Patrascu’05] [Gronlund,Pettie’14]

we prove a simplified version: Thm: Without bit-tricks, 3SUM is in time 𝑃(π‘œ1 β‹…

=87> 789 789 < 789 <

) using FFT: 𝑃(π‘œ + 𝑉 polylog𝑉) for numbers in {βˆ’π‘‰, …, 𝑉} (cell size π‘₯ = Ξ©(logπ‘œ), each number fits in a cell)

slide-4
SLIDE 4

Equivalent Variants

given sets 𝐡,𝐢,𝐷 of π‘œ integers are there 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢,𝑑 ∈ 𝐷 such that 𝑏 + 𝑐 + 𝑑 = 0? 1) given a set π‘Œ of π‘œ integers are there 𝑦, 𝑧, 𝑨 ∈ π‘Œ such that 𝑦 + 𝑧 + 𝑨 = 0? 4) given sets 𝐡,𝐢,𝐷 of π‘œ integers and target 𝑒 are there 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢,𝑑 ∈ 𝐷 such that 𝑏 + 𝑐 + 𝑑 = 𝑒? 3) given sets 𝐡,𝐢,𝐷 of π‘œ integers are there 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢,𝑑 ∈ 𝐷 such that 𝑏 + 𝑐 = 𝑑? 2) replace 𝐷 by 𝑑 βˆ’ 𝑒 𝑑 ∈ 𝐷} ⇔ 𝑏 + 𝑐 βˆ’ 𝑑 = 0 ⇔ 𝑏 + 𝑐 + (𝑑 βˆ’ 𝑒) = 0 replace 𝐷 by βˆ’π‘‘ 𝑑 ∈ 𝐷} ↑: set 𝐡, 𝐢, 𝐷 ≔ π‘Œ ↓: set π‘Œ ≔ 𝑏 + 4𝑉 | 𝑏 ∈ 𝐡 βˆͺ 𝐢 βˆͺ {𝑑 βˆ’ 4𝑉 | 𝑑 ∈ 𝐷} where 𝐡,𝐢,𝐷 βŠ† {βˆ’π‘‰,. . , 𝑉}

slide-5
SLIDE 5

Outline

1) algorithm for small universe 2) quadratic algorithm 3) small decision tree 4) logfactor improvement 5) some 3SUM-hardness results

slide-6
SLIDE 6

Algorithm for Small Numbers

add 𝑉 to each number, then numbers are in {0,. . , 2𝑉} and 𝑃(π‘œ + 𝑉 polylog𝑉) for numbers in {βˆ’π‘‰, …, 𝑉} we want 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢,𝑑 ∈ 𝐷 such that 𝑏 + 𝑐 + 𝑑 = 3𝑉 define polynomials π‘ž\ 𝑦 ≔ βˆ‘ 𝑦^

^∈\

and similarly π‘ž_ 𝑦 , π‘ž` 𝑦 have degree at most 2𝑉 compute π‘Ÿ 𝑦 ≔ π‘ž\ 𝑦 β‹… π‘ž_ 𝑦 β‹… π‘ž` 𝑦 = (βˆ‘ 𝑦^

^∈\

)(βˆ‘ 𝑦b

b∈_

)(βˆ‘ 𝑦c

c∈`

) what is the coefficient of 𝑦/d in π‘Ÿ(𝑦)? use efficient polynomial multiplication (via Fast Fourier Transform): polynomials of degree 𝑒 can be multiplied in time 𝑃(𝑒 polylog𝑒) (𝑦^ β‹… 𝑦b β‹… 𝑦c = 𝑦^fbfc) it is the number of (𝑏, 𝑐, 𝑑) summing to 3𝑉

slide-7
SLIDE 7

Outline

1) algorithm for small universe 2) quadratic algorithm 3) small decision tree 4) logfactor improvement 5) some 3SUM-hardness results

slide-8
SLIDE 8

Quadratic Algorithm

given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 𝑏g 𝑏1 𝑏/ 𝑏< … 𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

return β€œno solution”

slide-9
SLIDE 9

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-10
SLIDE 10

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-11
SLIDE 11

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-12
SLIDE 12

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-13
SLIDE 13

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-14
SLIDE 14

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-15
SLIDE 15

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-16
SLIDE 16

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

if 𝑏m + 𝑏

n < βˆ’π‘‘: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-17
SLIDE 17

Quadratic Algorithm

𝑏g 𝑏1 𝑏/ 𝑏< … initialize 𝑗 = π‘œ,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ: return β€œno solution” time 𝑃(π‘œ) per 𝑑 ∈ 𝐡 time 𝑃(π‘œ1) overall given a set 𝐡 of π‘œ integers are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? sort 𝐡 in increasing order: 𝐡 = {𝑏g,… , 𝑏<} for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 if 𝑏m + 𝑏

n = βˆ’π‘‘: return (𝑏m, 𝑏 n,𝑑)

if 𝑏m + 𝑏

n > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

  • therwise: π‘˜ ≔ π‘˜ + 1

𝑏g 𝑏1 𝑏/ 𝑏< …

slide-18
SLIDE 18

Outline

1) algorithm for small universe 2) quadratic algorithm 3) small decision tree 4) logfactor improvement 5) some 3SUM-hardness results

slide-19
SLIDE 19

Decision Tree Complexity

Thm: 3SUM has a decision tree of depth 𝑃(π‘œ//1 logπ‘œ)

slide-20
SLIDE 20

Decision Tree Complexity

where you have seen this: Thm: Any decision tree for Sorting π‘œ numbers has depth Ξ©(π‘œ logπ‘œ) Thm: Any comparison-based Sorting algorithm takes time Ξ©(π‘œlog π‘œ) problem 𝑄 on input 𝑦g,…, 𝑦< decision tree complexity of 𝑄 = minimal depth of any decision tree for 𝑄 Decision Tree: each inner node is a comparison: 𝑦m ≀ 𝑦n more generally any linear combination: βˆ‘ 𝛽m

m

𝑦m β‰₯ 0 all instances reaching the same leaf have the same result 𝑄(𝑦g,… ,𝑦<) 𝑦g ≀ 𝑦1 𝑦1 ≀ 𝑦/ 𝑦g ≀ 𝑦/

  • utgoing edges are labeled 1/0 = true/false

1 1 … … … 1 yields a lower bound for running time of any algorithm (that uses only comparisons, no bit-tricks)

slide-21
SLIDE 21

Decision Tree Complexity

alternative interpretation: think of 𝑦g,… ,𝑦< as physical entities we may specify factors 𝛽m we can perform experiments: the outcome of the experiment tells us whether βˆ‘ 𝛽m

m

𝑦m β‰₯ 0 experiments are very costly, computation is cheap what is the minimal number of experiments to decide 𝑄(𝑦g,… ,𝑦<)?

β€žexperimentβ€œ or β€žcostly comparisonβ€œ

= decision tree complexity

slide-22
SLIDE 22

Decision Tree Complexity

alternative interpretation II: RAM with two types of cells: special and standard input numbers 𝑦g,… ,𝑦< are stored in special cells special standard Stores: e.g. real number 𝑃(log π‘œ) bit number Operations: add, subtract, compare (result of comparison can be stored in standard cell) all standard arithmetic and logical operations and comparisons usual RAM cost model: each operations takes constant time decision tree cost model: comparisons of special numbers cost 1 all other operations are for free

slide-23
SLIDE 23

Decision Tree Complexity

Thm: 3SUM has a decision tree of depth 𝑃(π‘œ//1 logπ‘œ) why study decision tree upper bounds? rules out quadratic lower bound in decision tree model

  • ften small decision trees yield lower order improvements

Thm: Without bit-tricks, 3SUM is in time 𝑃(π‘œ1 β‹…

=87> 789 789 < 789 <

)

slide-24
SLIDE 24

Small Decision Tree

sort 𝐡 in increasing order partition 𝐡 into π‘œ/𝑕 groups: 𝐡g, …, 𝐡</u (all elements of 𝐡m are smaller than all elements of 𝐡mfg) sort 𝐸 ≔ ⋃ 𝐡m βˆ’ 𝐡m

</u mxg

= 𝑏 βˆ’ 𝑐 βˆƒπ‘—: 𝑏, 𝑐 ∈ 𝐡m} given a set 𝐡 of π‘œ integers, are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? write 𝐡m = {𝑏m,g,…, 𝑏m,u} i.e., build a list 𝑀| containing all (𝑗, π‘˜, 𝑙) with 𝑗 ∈ 1,… , π‘œ/𝑕 , π‘˜, 𝑙 ∈ {1, … ,𝑕} sorted by 𝑏m,n βˆ’ 𝑏m,~ ascendingly this preprocessing allows to compare any 𝑏m,n βˆ’ 𝑏m,~ and 𝑏mβ€’,nβ€’ βˆ’ 𝑏mβ€’,~β€’ without any costly comparisons Fredman’s trick: 𝑏m,n + 𝑏mβ€’,nβ€’ ≀ 𝑏m,~ + 𝑏mβ€’,~β€’ ⟺ 𝑏mβ€’,nβ€’ βˆ’ 𝑏mβ€’,~β€’ ≀ 𝑏m,~ βˆ’ 𝑏m,n so this preprocessing allows to compare any 𝑏m,n + 𝑏mβ€’,nβ€’ and 𝑏m,~ + 𝑏mβ€’,~β€’ without any costly comparisons: 𝑃 𝐸 log 𝐸 = 𝑃(π‘œπ‘• log(π‘œπ‘•)) comparisons 𝑃(π‘œ logπ‘œ) comparisons 𝑏m,n + 𝑏mβ€’,nβ€’ ≀ 𝑏m,~ + 𝑏mβ€’,~β€’ ⟺ (𝑗‒,π‘˜β€’,𝑙‒) appears before (𝑗, 𝑙, π‘˜) in 𝑀| any numbers in 𝐡m,mβ€’ ≔ 𝐡m + 𝐡mβ€’ = 𝑏 + 𝑐 𝑏 ∈ 𝐡m, 𝑐 ∈ 𝐡mβ€’}

slide-25
SLIDE 25

Small Decision Tree

sort 𝐡 in increasing order for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 𝐡g 𝐡1 𝐡</u … 𝐡g 𝐡1 𝐡</u … initialize 𝑗 = π‘œ/𝑕,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ/𝑕: if βˆ’π‘‘ ∈ 𝐡m,n: return β€œsolution found” if min 𝐡m + max (𝐡

n) > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

  • therwise: π‘˜ ≔ π‘˜ + 1

return β€œno solution” partition 𝐡 into π‘œ/𝑕 groups: 𝐡g, …, 𝐡</u (all elements of 𝐡m are smaller than all elements of 𝐡mfg) sort 𝐸 ≔ ⋃ 𝐡m βˆ’ 𝐡m

</u mxg

= 𝑏 βˆ’ 𝑐 βˆƒπ‘—: 𝑏, 𝑐 ∈ 𝐡m} given a set 𝐡 of π‘œ integers, are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? for all 𝑗, 𝑗‒: sort 𝐡m,mβ€’ ≔ 𝐡m + 𝐡mβ€’ = 𝑏 + 𝑐 𝑏 ∈ 𝐡m, 𝑐 ∈ 𝐡mβ€’} 𝑃 𝐸 log 𝐸 = 𝑃(π‘œπ‘• log(π‘œπ‘•)) comparisons 𝑃(π‘œ logπ‘œ) comparisons no comparisons!

slide-26
SLIDE 26

Small Decision Tree

sort 𝐡 in increasing order for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 𝐡g 𝐡1 𝐡</u … 𝐡g 𝐡1 𝐡</u … initialize 𝑗 = π‘œ/𝑕,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ/𝑕: if βˆ’π‘‘ ∈ 𝐡m,n: return β€œsolution found” if min 𝐡m + max (𝐡

n) > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

  • therwise: π‘˜ ≔ π‘˜ + 1

return β€œno solution” partition 𝐡 into π‘œ/𝑕 groups: 𝐡g, …, 𝐡</u (all elements of 𝐡m are smaller than all elements of 𝐡mfg) sort 𝐸 ≔ ⋃ 𝐡m βˆ’ 𝐡m

</u mxg

= 𝑏 βˆ’ 𝑐 βˆƒπ‘—: 𝑏, 𝑐 ∈ 𝐡m} given a set 𝐡 of π‘œ integers, are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? for all 𝑗, 𝑗‒: sort 𝐡m,mβ€’ ≔ 𝐡m + 𝐡mβ€’ = 𝑏 + 𝑐 𝑏 ∈ 𝐡m, 𝑐 ∈ 𝐡mβ€’} 𝑃 𝐸 log 𝐸 = 𝑃(π‘œπ‘• log(π‘œπ‘•)) comparisons 𝑃(π‘œ logπ‘œ) comparisons no comparisons!

slide-27
SLIDE 27

Small Decision Tree

sort 𝐡 in increasing order for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 𝐡g 𝐡1 𝐡</u … 𝐡g 𝐡1 𝐡</u … initialize 𝑗 = π‘œ/𝑕,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ/𝑕: if βˆ’π‘‘ ∈ 𝐡m,n: return β€œsolution found” if min 𝐡m + max (𝐡

n) > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

  • therwise: π‘˜ ≔ π‘˜ + 1

return β€œno solution” partition 𝐡 into π‘œ/𝑕 groups: 𝐡g, …, 𝐡</u (all elements of 𝐡m are smaller than all elements of 𝐡mfg) sort 𝐸 ≔ ⋃ 𝐡m βˆ’ 𝐡m

</u mxg

= 𝑏 βˆ’ 𝑐 βˆƒπ‘—: 𝑏, 𝑐 ∈ 𝐡m} given a set 𝐡 of π‘œ integers, are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? for all 𝑗, 𝑗‒: sort 𝐡m,mβ€’ ≔ 𝐡m + 𝐡mβ€’ = 𝑏 + 𝑐 𝑏 ∈ 𝐡m, 𝑐 ∈ 𝐡mβ€’} 𝑃 𝐸 log 𝐸 = 𝑃(π‘œπ‘• log(π‘œπ‘•)) comparisons 𝑃(π‘œ logπ‘œ) comparisons no comparisons!

slide-28
SLIDE 28

Small Decision Tree

sort 𝐡 in increasing order for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 initialize 𝑗 = π‘œ/𝑕,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ/𝑕: if βˆ’π‘‘ ∈ 𝐡m,n: return β€œsolution found” if min 𝐡m + max (𝐡

n) > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

  • therwise: π‘˜ ≔ π‘˜ + 1

return β€œno solution” partition 𝐡 into π‘œ/𝑕 groups: 𝐡g, …, 𝐡</u (all elements of 𝐡m are smaller than all elements of 𝐡mfg) sort 𝐸 ≔ ⋃ 𝐡m βˆ’ 𝐡m

</u mxg

= 𝑏 βˆ’ 𝑐 βˆƒπ‘—: 𝑏, 𝑐 ∈ 𝐡m} given a set 𝐡 of π‘œ integers, are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? for all 𝑗, 𝑗‒: sort 𝐡m,mβ€’ ≔ 𝐡m + 𝐡mβ€’ = 𝑏 + 𝑐 𝑏 ∈ 𝐡m, 𝑐 ∈ 𝐡mβ€’} 𝑃 𝐸 log 𝐸 = 𝑃(π‘œπ‘• log(π‘œπ‘•)) comparisons 𝑃(π‘œ logπ‘œ) comparisons no comparisons! 𝑃 π‘œ/𝑕 iterations 𝑃 log(𝑕1) = 𝑃(logπ‘œ) comparisons using binary search π‘œ iterations in total: 𝑃((π‘œπ‘• + π‘œ1/𝑕)log π‘œ) comparisons = 𝑃(π‘œ//1 logπ‘œ) for 𝑕 ≔ π‘œ

slide-29
SLIDE 29

Decision Tree Complexity

Thm: 3SUM has a decision tree of depth 𝑃(π‘œ//1 logπ‘œ) Thm: Without bit-tricks, 3SUM is in time 𝑃(π‘œ1 β‹…

=87> 789 789 < 789 <

)

slide-30
SLIDE 30

Outline

1) algorithm for small universe 2) quadratic algorithm 3) small decision tree 4) logfactor improvement 5) some 3SUM-hardness results

slide-31
SLIDE 31

Converting Decision Tree to Algorithm

sort 𝐡 in increasing order for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 initialize 𝑗 = π‘œ/𝑕,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ/𝑕: if βˆ’π‘‘ ∈ 𝐡m,n: return β€œsolution found” if min 𝐡m + max (𝐡

n) > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

  • therwise: π‘˜ ≔ π‘˜ + 1

return β€œno solution” partition 𝐡 into π‘œ/𝑕 groups: 𝐡g, …, 𝐡</u (all elements of 𝐡m are smaller than all elements of 𝐡mfg) sort 𝐸 ≔ ⋃ 𝐡m βˆ’ 𝐡m

</u mxg

= 𝑏 βˆ’ 𝑐 βˆƒπ‘—: 𝑏, 𝑐 ∈ 𝐡m} given a set 𝐡 of π‘œ integers, are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? for all 𝑗, 𝑗‒: sort 𝐡m,mβ€’ ≔ 𝐡m + 𝐡mβ€’ = 𝑏 + 𝑐 𝑏 ∈ 𝐡m, 𝑐 ∈ 𝐡mβ€’} 𝑃 𝐸 log 𝐸 = 𝑃(π‘œπ‘• log(π‘œπ‘•)) comparisons and time 𝑃(π‘œ logπ‘œ) comparisons and time no comparisons! 𝑃( π‘œ/𝑕 1 β‹… 𝑕1 log(𝑕1)) time 𝑃 π‘œ/𝑕 iterations 𝑃 log(𝑕1) = 𝑃(logπ‘œ) comparisons and time using binary search π‘œ iterations in total: 𝑃(π‘œ1 log(𝑕1)) time ☹

slide-32
SLIDE 32

Converting Decision Tree to Algorithm

for all 𝒋,𝒋‒: sort 𝑩𝒋,𝒋‒ ≔ 𝑩𝒋 + 𝑩𝒋‒ = 𝒃 + 𝒄 𝒃 ∈ 𝑩𝒋,𝒄 ∈ 𝑩𝒋‒} write 𝐡m = {𝑏m,g,…, 𝑏m,u} make 𝐡m,mβ€’ totally ordered: replace 𝐡m by 𝑏m,n β‹… 2𝑕 1 + π‘˜ 1 ≀ π‘˜ ≀ 𝑕} replace 𝐡mβ€’ by 𝑏mβ€’,n β‹… 2𝑕 1 + π‘˜ β‹… 2𝑕 1 ≀ π‘˜ ≀ 𝑕} then no 𝒃 ∈ 𝑩𝒋, 𝒄 ∈ 𝑩𝒋‒ and 𝒃′ ∈ 𝑩𝒋, 𝒄′ ∈ 𝑩𝒋‒ sum up to the same value simplification: and from the new 𝐡m + 𝐡mβ€’ we can recover the old 𝐡m + 𝐡mβ€’ implement this step faster!

slide-33
SLIDE 33

Converting Decision Tree to Algorithm

for all 𝒋,𝒋‒: sort 𝑩𝒋,𝒋‒ ≔ 𝑩𝒋 + 𝑩𝒋‒ = 𝒃 + 𝒄 𝒃 ∈ 𝑩𝒋,𝒄 ∈ 𝑩𝒋‒} write 𝐡m = {𝑏m,g,…, 𝑏m,u} consider any permutation 𝑄 = 𝜌g,𝜏g , 𝜌1,𝜏1 ,… , 𝜌u:,𝜏u:

  • f 1, . ., 𝑕 Γ—{1, …, 𝑕}

this is the correct sorted ordering of 𝐡m,mβ€’ if and only if: 𝑄 corresponds to this ordering of 𝐡m,mβ€’: (𝑏m,β€’β€’ + 𝑏mβ€’,β€˜β€’ 𝑏m,β€’: + 𝑏mβ€’,β€˜: … 𝑏m,‒’ + 𝑏mβ€’,β€˜β€™) 𝑏m,β€’β€œ + 𝑏mβ€’,β€˜β€œ < 𝑏m,β€’β€œβ€β€’ + 𝑏mβ€’,β€˜β€œβ€β€’ for all 1 ≀ 𝑙 < 𝑕1 by Fredmanβ€˜s trick, this is equivalent to: 𝑏mβ€’,β€˜β€œ βˆ’ 𝑏mβ€’,β€˜β€œβ€β€’ < 𝑏m,β€’β€œβ€β€’ βˆ’ 𝑏m,β€’β€œ for all 1 ≀ 𝑙 < 𝑕1 construct vectors: (𝑏mβ€’,β€˜β€œ βˆ’ 𝑏mβ€’,β€˜β€œβ€β€’)gβ€’~–u: (𝑏m,β€’β€œβ€β€’ βˆ’ 𝑏m,β€’β€œ)gβ€’~–u: we say that vector 𝑦 dominates vector 𝑧 if 𝑦m > 𝑧m for all 𝑗

slide-34
SLIDE 34

Dominance Reporting

Dominance Reporting problem: given sets 𝐡,𝐢 of (integer-valued) vectors in β„Λœ, 𝐡 + 𝐢 = 𝑛 report all pairs 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢 where 𝑐 dominates 𝑏 Thm: Dominance Reporting is in time 𝑃 𝑛 log𝑛 ˜ + outputsize

slide-35
SLIDE 35

Converting Decision Tree to Algorithm

for all 𝒋,𝒋‒: sort 𝑩𝒋,𝒋‒ ≔ 𝑩𝒋 + 𝑩𝒋‒ = 𝒃 + 𝒄 𝒃 ∈ 𝑩𝒋,𝒄 ∈ 𝑩𝒋‒} write 𝐡m = {𝑏m,g,…, 𝑏m,u} for each permutation 𝑄 = 𝜌g,𝜏g , 𝜌1,𝜏1 ,… , 𝜌u:,𝜏u:

  • f 1, . ., 𝑕 Γ—{1, …, 𝑕}:

construct sets: (𝑏mβ€’,β€˜β€œ βˆ’ 𝑏mβ€’,β€˜β€œβ€β€’)gβ€’~–u: (𝑏m,β€’β€œβ€β€’ βˆ’ 𝑏m,β€’β€œ)gβ€’~–u: 𝐡 = { 𝐢 = { | 1 ≀ 𝑗‒ ≀ π‘œ/𝑕 } | 1 ≀ 𝑗 ≀ π‘œ/𝑕 } solve Dominance Reporting on 𝐡,𝐢 for each reported pair (𝑗, 𝑗‒): the sorted ordering of 𝐡m,mβ€’ is given by 𝑄: (𝑏m,β€’β€’ + 𝑏mβ€’,β€˜β€’ 𝑏m,β€’: + 𝑏mβ€’,β€˜: … 𝑏m,‒’ + 𝑏mβ€’,β€˜β€™) time for sorting all 𝐡m,mβ€’: 𝑃 𝑕1 ! β‹… (π‘œ/𝑕)(logπ‘œ/𝑕)u: + π‘œ/𝑕 1

  • ne vector

for each of π‘œ/𝑕 groups 𝑕1 ! iterations vectors have dimension 𝑕1 total

  • utputsize

π‘œ/𝑕 1 time 𝑃(𝑛 log𝑛 ˜ + outputsize)

slide-36
SLIDE 36

Converting Decision Tree to Algorithm

for all 𝒋,𝒋‒: sort 𝑩𝒋,𝒋‒ ≔ 𝑩𝒋 + 𝑩𝒋‒ = 𝒃 + 𝒄 𝒃 ∈ 𝑩𝒋,𝒄 ∈ 𝑩𝒋‒} write 𝐡m = {𝑏m,g,…, 𝑏m,u} for each permutation 𝑄 = 𝜌g,𝜏g , 𝜌1,𝜏1 ,… , 𝜌u:,𝜏u:

  • f 1, . ., 𝑕 Γ—{1, …, 𝑕}:

construct sets: (𝑏mβ€’,β€˜β€œ βˆ’ 𝑏mβ€’,β€˜β€œβ€β€’)gβ€’~–u: (𝑏m,β€’β€œβ€β€’ βˆ’ 𝑏m,β€’β€œ)gβ€’~–u: 𝐡 = { 𝐢 = { | 1 ≀ 𝑗‒ ≀ π‘œ/𝑕 } | 1 ≀ 𝑗 ≀ π‘œ/𝑕 } solve Dominance Reporting on 𝐡,𝐢 for each reported pair (𝑗, 𝑗‒): the sorted ordering of 𝐡m,mβ€’ is given by 𝑄: (𝑏m,β€’β€’ + 𝑏mβ€’,β€˜β€’ 𝑏m,β€’: + 𝑏mβ€’,β€˜: … 𝑏m,‒’ + 𝑏mβ€’,β€˜β€™) time for sorting all 𝐡m,mβ€’: 𝑃 𝑕1 ! β‹… (π‘œ/𝑕)(logπ‘œ/𝑕)u: + π‘œ/𝑕 1 time 𝑃(𝑛 log𝑛 ˜ + outputsize) setting 𝑕 ≔ 0.1 β‹… log π‘œ/ loglog π‘œ 𝑕1 ! ≀ 𝑕1

u: ≀ (logπ‘œ)u:≀ logπ‘œ ( . g 789 <)/789 789 < = π‘œ . g

(logπ‘œ/𝑕)u:≀ logπ‘œ u: ≀ π‘œ . g = 𝑃 π‘œ/𝑕 1

slide-37
SLIDE 37

Converting Decision Tree to Algorithm

sort 𝐡 in increasing order for each 𝑑 ∈ 𝐡: check whether there are 𝑏, 𝑐 ∈ 𝐡 s.t. 𝑏 + 𝑐 + 𝑑 = 0 initialize 𝑗 = π‘œ/𝑕,π‘˜ = 1 while 𝑗 > 0 and π‘˜ ≀ π‘œ/𝑕: if βˆ’π‘‘ ∈ 𝐡m,n: return β€œsolution found” if min 𝐡m + max (𝐡

n) > βˆ’π‘‘: 𝑗 ≔ 𝑗 βˆ’ 1

  • therwise: π‘˜ ≔ π‘˜ + 1

return β€œno solution” partition 𝐡 into π‘œ/𝑕 groups: 𝐡g, …, 𝐡</u (all elements of 𝐡m are smaller than all elements of 𝐡mfg) sort 𝐸 ≔ ⋃ 𝐡m βˆ’ 𝐡m

</u mxg

= 𝑏 βˆ’ 𝑐 βˆƒπ‘—: 𝑏, 𝑐 ∈ 𝐡m} given a set 𝐡 of π‘œ integers, are there 𝑏, 𝑐, 𝑑 ∈ 𝐡 such that 𝑏 + 𝑐 + 𝑑 = 0? for all 𝑗, 𝑗‒: sort 𝐡m,mβ€’ ≔ 𝐡m + 𝐡mβ€’ = 𝑏 + 𝑐 𝑏 ∈ 𝐡m, 𝑐 ∈ 𝐡mβ€’} 𝑃 𝐸 log 𝐸 = 𝑃(π‘œπ‘• log(π‘œπ‘•)) comparisons and time 𝑃(π‘œ logπ‘œ) comparisons and time no comparisons! 𝑃( π‘œ/𝑕 1 β‹… 𝑕1 log(𝑕1)) time 𝑃 π‘œ/𝑕 iterations 𝑃 log(𝑕1) = 𝑃(logπ‘œ) comparisons and time using binary search π‘œ iterations in total: 𝑃(π‘œ1 log(𝑕)/𝑕) time for 𝑕 ≔ 0.1 β‹… log π‘œ/ loglog π‘œ: 𝑃(π‘œ1 =87> 789 789 <

789 <

) time

slide-38
SLIDE 38

Decision Tree Complexity

Thm: 3SUM has a decision tree of depth 𝑃(π‘œ//1 logπ‘œ) Thm: Without bit-tricks, 3SUM is in time 𝑃(π‘œ1 β‹…

=87> 789 789 < 789 <

)

slide-39
SLIDE 39

Dominance Reporting

Dominance Reporting problem: given sets 𝐡,𝐢 of (integer-valued) vectors in β„Λœ, 𝐡 + 𝐢 = 𝑛 report all pairs 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢 where 𝑐 dominates 𝑏 Thm: deciding whether there is a dominating pair (𝑏, 𝑐) is OV-hard so we do not expect an 𝑃(poly 𝑒 𝑛123) algorithm OV is in time 𝑃(2Λœπ‘›) the theorem β€žgeneralizesβ€œ this OV-algorithm to Dominance Reporting Dominance Reporting is in time 𝑃 𝑛 log𝑛 ˜ + outputsize

slide-40
SLIDE 40

Dominance Reporting

Dominance Reporting problem: given sets 𝐡,𝐢 of (integer-valued) vectors in β„Λœ, 𝐡 + 𝐢 = 𝑛 report all pairs 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢 where 𝑐 dominates 𝑏 if 𝑒 = 0: report all pairs 𝐡×𝐢

  • therwise:

find median 𝑦 of 𝑒-th coordinates of all points in 𝐡 βˆͺ 𝐢 - time 𝑃(𝑛) assume all coordinates to be different 𝐡‘ ≔ 𝑏 ∈ 𝐡 π‘Λœ < 𝑦} and 𝐡’ ≔ 𝐡\𝐡‘ 𝐢‘ ≔ 𝑐 ∈ 𝐢 π‘Λœ < 𝑦} and 𝐢’ ≔ 𝐢\𝐢

Β‘

recursively solve 𝐡’, 𝐢’ ,(𝐡‘, 𝐢

‘ ), and (𝐡‘,𝐢’ )

remove 𝑒-th coordinates! π‘ˆΛœ 𝑛 ≀ 2π‘ˆΛœ 𝑛/2 + π‘ˆΛœ2g 𝑛 + 𝑛 Thm: Dominance Reporting is in time 𝑃 𝑛 log𝑛 ˜ + outputsize

slide-41
SLIDE 41

Dominance Reporting

π‘ˆΛœ 𝑛 ≀ 2π‘ˆΛœ 𝑛/2 + π‘ˆΛœ2g 𝑛 + 𝑛 π‘ˆ 𝑛 = π‘ˆΛœ 1 = 0 Excluding cost of output: π‘ˆΛœ 𝑛 ≀ 𝑛 log2𝑛 ˜ βˆ’ 𝑛 Inductively prove that: π‘ˆΛœ 𝑛 ≀ 2 𝑛 2 log𝑛 ˜ βˆ’ 𝑛 2 + 𝑛 log2𝑛 ˜2g βˆ’ 𝑛 + 𝑛 = 𝑛 (log2𝑛) βˆ’ 1 ˜ + 𝑛 (log2𝑛)˜2gβˆ’π‘› = 𝑛 (log 2𝑛)˜ 1 βˆ’ 1/ log2𝑛 ˜ + 𝑛 (log2𝑛)˜2gβˆ’π‘› ≀ 𝑛 (log 2𝑛)˜ 1 βˆ’ 1/ log2𝑛 + 𝑛 (log2𝑛)˜2gβˆ’π‘› = 𝑛 (log 2𝑛)˜ βˆ’ 𝑛

slide-42
SLIDE 42

Dominance Reporting

Dominance Reporting problem: given sets 𝐡,𝐢 of (integer-valued) vectors in β„Λœ, 𝐡 + 𝐢 = 𝑛 report all pairs 𝑏 ∈ 𝐡, 𝑐 ∈ 𝐢 where 𝑐 dominates 𝑏 Thm: Dominance Reporting is in time 𝑃 𝑛 log𝑛 ˜ + outputsize Thm: Without bit-tricks, 3SUM is in time 𝑃(π‘œ1 β‹…

=87> 789 789 < 789 <

) this finishes the proof of:

slide-43
SLIDE 43

Outline

1) algorithm for small universe 2) quadratic algorithm 3) small decision tree 4) logfactor improvement 5) some 3SUM-hardness results

slide-44
SLIDE 44

GeomBase

given a set of π‘œ points on three horinzontal lines 𝑧 = 0,𝑧 = 1, 𝑧 = 2, determine whether there exists a non-horizontal line containing three of the points GeomBase is even equivalent to 3SUM Thm: GeomBase is 3SUM-hard. Given an instance (𝐡, 𝐢, 𝐷) of 3SUM 𝑧 = 0 𝑧 = 1 𝑧 = 2 construct points: (𝑏, 0) for any 𝑏 ∈ 𝐡 (𝑐,2) for any 𝑐 ∈ 𝐢 (𝑑/2,1) for any 𝑑 ∈ 𝐷 they lie on a line if 𝑑/2 βˆ’ 𝑏 = 𝑐 βˆ’ 𝑑/2 ⇔ 𝑏 + 𝑐 = 𝑑

slide-45
SLIDE 45

3-Points-on-line / Collinear

given a set of π‘œ points in the plane, is there a line containing at least 3 of the points? Thm: 3-Points-on-line is 3SUM-hard. Given an instance 𝐡 of 3SUM construct points: (𝑏, 𝑏/) for any 𝑏 ∈ 𝐡 then 𝑏, 𝑏/ , 𝑑, 𝑑/ , 𝑑,𝑑/ are collinear if and only if 𝑏 + 𝑐 + 𝑑 = 0 (without proof)

slide-46
SLIDE 46

3-Points-on-line / Collinear

given a set of π‘œ possibly half-infinite, closed horizontal line segments, is there a non-horizontal separator? Thm: Separator is 3SUM-hard.

slide-47
SLIDE 47

Planar Motion Planning

given a set of line segment obstacles in the plane and a line segment robot, decide whether the robot can be moved (allowing translation and rotation) from a given source to a given goal configuration without colliding with the obstacles. Thm: PlanarMotionPlanning is 3SUM-hard.