155
1-1 Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with Amotz Bar-Noy, Yi Feng, Rudolf Fleischer, Yan Zhang (Revision of 18/6/08)

Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

  • Upload
    vanngoc

  • View
    216

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

1-1

Revisiting The Monge Property

Mordecai GolinHong Kong UST

Joint Work withAmotz Bar-Noy, Yi Feng,Rudolf Fleischer, Yan Zhang

(Revision of 18/6/08)

Page 2: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

2-1

Well known that, under “special”circumstances, Dynamic Programmingcan be sped up.

Page 3: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

2-2

(a) H(i) = min0≤j<i

(H(j) + w(j, i)

)

Well known that, under “special”circumstances, Dynamic Programmingcan be sped up.

Page 4: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

2-3

(a) H(i) = min0≤j<i

(H(j) + w(j, i)

)

Well known that, under “special”circumstances, Dynamic Programmingcan be sped up.

(b) H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)

Page 5: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

2-4

(a) H(i) = min0≤j<i

(H(j) + w(j, i)

)

Well known that, under “special”circumstances, Dynamic Programmingcan be sped up.

(b) H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)

Θ(n2) time

0 ≤ i ≤ n0 ≤ d ≤ D

0 ≤ i ≤ n

Θ(Dn2) time

Page 6: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

2-5

(a) H(i) = min0≤j<i

(H(j) + w(j, i)

)

Well known that, under “special”circumstances, Dynamic Programmingcan be sped up.

(b) H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)

Θ(n2) time

0 ≤ i ≤ n0 ≤ d ≤ D

0 ≤ i ≤ n

Θ(Dn2) time

+ Monge Property

Page 7: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

2-6

(a) H(i) = min0≤j<i

(H(j) + w(j, i)

)

Well known that, under “special”circumstances, Dynamic Programmingcan be sped up.

(b) H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)

Θ(n2) time

0 ≤ i ≤ n0 ≤ d ≤ D

0 ≤ i ≤ n

Θ(Dn2) time

+ Monge Property

Θ(n) time

Θ(Dn) time

Page 8: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

3-1

H(i) = min0≤j<i

(H(j) + w(j, i)

)H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

Page 9: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

3-2

H(i) = min0≤j<i

(H(j) + w(j, i)

)H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

n2 → nDn2 → Dn

Page 10: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

3-3

H(i) = min0≤j<i

(H(j) + w(j, i)

)H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

n2 → nDn2 → Dn

Calculating H(n, D) requires only O(n) space.Constructing explicit path in DP table yielding this solution,requires storing entire DP table ⇒ Θ(Dn) space.

Page 11: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

3-4

H(i) = min0≤j<i

(H(j) + w(j, i)

)H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

n2 → nDn2 → Dn

Calculating H(n, D) requires only O(n) space.Constructing explicit path in DP table yielding this solution,requires storing entire DP table ⇒ Θ(Dn) space.

First new result is reduction to O(n) space.

Page 12: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

3-5

H(i) = min0≤j<i

(H(j) + w(j, i)

)H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

n2 → nDn2 → Dn

Speedup works by batching calculations.Data (the w(j, i)) must be known in advance so that proper batch-ing order can be used. In particular, speedup fails if data is givenonline, i.e., i = 1, 2, 3, . . ..

Calculating H(n, D) requires only O(n) space.Constructing explicit path in DP table yielding this solution,requires storing entire DP table ⇒ Θ(Dn) space.

First new result is reduction to O(n) space.

Page 13: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

3-6

H(i) = min0≤j<i

(H(j) + w(j, i)

)H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

n2 → nDn2 → Dn

Speedup works by batching calculations.Data (the w(j, i)) must be known in advance so that proper batch-ing order can be used. In particular, speedup fails if data is givenonline, i.e., i = 1, 2, 3, . . ..

Calculating H(n, D) requires only O(n) space.Constructing explicit path in DP table yielding this solution,requires storing entire DP table ⇒ Θ(Dn) space.

First new result is reduction to O(n) space.

Second new result is how to maintain the speedup for online data;O(1) or O(D) per update.

Page 14: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

4-1

Outline

• Review of the Monge Speedup

• Maintaining the Speedup in anOnline Setting

• Saving Space While Saving Time

Page 15: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

5-1

The Monge Speedup• M is an m× n matrix

Page 16: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

5-2

The Monge Speedup• M is an m× n matrix

• RMM (i) is column index of (rightmost) min item on row i of M .

• M is Monotone if ∀i ≤ i′, RMM (i) ≤ RMM (i′).

Page 17: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

5-3

The Monge Speedup• M is an m× n matrix

• RMM (i) is column index of (rightmost) min item on row i of M .

7 2 4 3 9 95 1 5 1 6 57989

1446

557

2 01

3 13 243

5 6 53

RMM (1) = 2

RMM (2) = 4

RMM (3) = 4

RMM (4) = 4

RMM (5) = 6

RMM (6) = 6

• M is Monotone if ∀i ≤ i′, RMM (i) ≤ RMM (i′).

Page 18: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

5-4

The Monge Speedup• M is an m× n matrix

• RMM (i) is column index of (rightmost) min item on row i of M .

• M is Monotone if ∀i ≤ i′, RMM (i) ≤ RMM (i′).

• 2× 2 monotone matrices have form

2 45

7 12

2 334 5 2

• An m× n matrix M is Totally Monotone (TM)if every 2× 2 submatrix is Monotone.

(submatrix: not necessarily contiguous in the original matrix)

7 132

Page 19: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

6-1

SMAWK and LARSCH Algorithms• Motivation:

Find all m row minima of an implicitly given m× n matrix M

Page 20: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

6-2

SMAWK and LARSCH Algorithms• Motivation:

Find all m row minima of an implicitly given m× n matrix M

• Naive Algorithm: O(mn)

Page 21: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

6-3

SMAWK and LARSCH Algorithms• Motivation:

Find all m row minima of an implicitly given m× n matrix M

• Naive Algorithm: O(mn)

• SMAWK Algorithm[Aggarwal, Klawe, Moran, Shor, Wilber (1986)]

• If M is Totally Monotone,all m row minima can be found in O(m + n) time.

• Usually m = Θ(n)Θ(n) speedup: O(n2) down to O(n).

Page 22: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

6-4

SMAWK and LARSCH Algorithms• Motivation:

Find all m row minima of an implicitly given m× n matrix M

• Naive Algorithm: O(mn)

• SMAWK Algorithm[Aggarwal, Klawe, Moran, Shor, Wilber (1986)]

• If M is Totally Monotone,all m row minima can be found in O(m + n) time.

• Usually m = Θ(n)Θ(n) speedup: O(n2) down to O(n).

• SMAWK was culmination of decade(s) of work on similar problems;speedups using convexity and concavity.Has been used to speed up many DP problems, e.g., computationalgeometry, bioinformatics, k-center on a line, etc.

Page 23: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

6-5

SMAWK and LARSCH Algorithms• Motivation:

Find all m row minima of an implicitly given m× n matrix M

• Naive Algorithm: O(mn)

• SMAWK Algorithm[Aggarwal, Klawe, Moran, Shor, Wilber (1986)]

• If M is Totally Monotone,all m row minima can be found in O(m + n) time.

• Usually m = Θ(n)Θ(n) speedup: O(n2) down to O(n).

• LARSCH Algorithm [Larmore, Schieber (1991)]More complicated solution to same problem.Allows dependencies of Mi,j on earlier row minima in matrix.

Page 24: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

7-1

The Monge Property

• Motivation: TM is often established via Monge property

Page 25: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

7-2

The Monge Property

• Motivation: TM is often established via Monge property

• m× n matrix M is Monge if ∀i ≤ i′ and ∀j ≤ j′

Mi,j + Mi′,j′ ≤ Mi′,j + Mi,j′

Page 26: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

7-3

The Monge Property

• Motivation: TM is often established via Monge property

• m× n matrix M is Monge if ∀i ≤ i′ and ∀j ≤ j′

Mi,j + Mi′,j′ ≤ Mi′,j + Mi,j′

• M is Monge ⇒ M is Totally Monotone

Page 27: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

7-4

The Monge Property

• Motivation: TM is often established via Monge property

• m× n matrix M is Monge if ∀i ≤ i′ and ∀j ≤ j′

Mi,j + Mi′,j′ ≤ Mi′,j + Mi,j′

• M is Monge ⇒ M is Totally Monotone

• Also, if ∀i, j, Mi,j + Mi+1,j+1 ≤ Mi+1,j + Mi,j+1,⇒ M is Monge.

Page 28: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

7-5

The Monge Property

• Motivation: TM is often established via Monge property

• m× n matrix M is Monge if ∀i ≤ i′ and ∀j ≤ j′

Mi,j + Mi′,j′ ≤ Mi′,j + Mi,j′

• M is Monge ⇒ M is Totally Monotone

• Also, if ∀i, j, Mi,j + Mi+1,j+1 ≤ Mi+1,j + Mi,j+1,⇒ M is Monge.

• ⇒ Only need to prove Monge property foradjacent rows and columns.

Page 29: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

8-1

H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)Using The Monge Property

Suppose we are given DP (i.v. H(i, 0) known, i ≤ n, d ≤ D):

Page 30: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

8-2

H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)Using The Monge Property

Suppose we are given DP (i.v. H(i, 0) known, i ≤ n, d ≤ D):

For j < i, set Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

Page 31: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

8-3

H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)Using The Monge Property

Suppose we are given DP (i.v. H(i, 0) known, i ≤ n, d ≤ D):

For j < i, set Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

To calculate H(∗, d), simply find row-minima in M

Page 32: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

8-4

H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)Using The Monge Property

Suppose we are given DP (i.v. H(i, 0) known, i ≤ n, d ≤ D):

For j < i, set Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

To calculate H(∗, d), simply find row-minima in M

Fact: If w(d)(j, i) are Monge ⇒ M is Monge

Page 33: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

8-5

H(i, d) = min0≤j<i

(H(j, d−1)+w(d)(j, i)

)Using The Monge Property

Suppose we are given DP (i.v. H(i, 0) known, i ≤ n, d ≤ D):

For j < i, set Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

To calculate H(∗, d), simply find row-minima in M

Fact: If w(d)(j, i) are Monge ⇒ M is Monge

Then, for given d, SMAWK finds all H(∗, d) in O(n) time;iterating, finds all H(i, d) in O(nD) time.

Page 34: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

9-1

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Examples of

i ≤ n, d ≤ D

Page 35: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

9-2

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Examples of

i ≤ n, d ≤ D

• Length Limited Huffman Codes

w(d)(j, i) = S2j−i where Sk =∑k

i=1 pi.

0 ≤ p1 ≤ p2 ≤ · · · ≤ pn

H(n− 1, D) is cost of min-cost D-limited code

Page 36: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

9-3

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Examples of

i ≤ n, d ≤ D

• Length Limited Huffman Codes

w(d)(j, i) = S2j−i where Sk =∑k

i=1 pi.

0 ≤ p1 ≤ p2 ≤ · · · ≤ pn

H(n− 1, D) is cost of min-cost D-limited code

• Wireless mobile paging p1 ≥ p2 ≥ · · · ≥ pn ≥ 0

w(d)(j, i) = i(∑i

`=j+1 p`

)H(n, D) is min expected bandwidth required to page allitems using ≤ D paging rounds

Page 37: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

10-1

• D-Medians on a Directed Line

w1 w2 w3 w4 wn−1 wn

d1 d2 d3 dn−1

Woeginger ’00

Page 38: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

10-2

• D-Medians on a Directed Line

w1 w2 w3 w4 wn−1 wn

d1 d2 d3 dn−1

Identify D nodes as service centers.

Nodes can only be serviced by node to their left (or themselves)so node 1 must be a service center.

Cost of servicing request wi, is wi times distance from node ito nearest service center.

Problem is to find location of D service centersthat minimize total service cost.

Woeginger ’00

Page 39: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

10-3

• D-Medians on a Directed Line

w1 w2 w3 w4 wn−1 wn

d1 d2 d3 dn−1

Let H(i, d) be cost ofservicing nodes [1, i] using exactly d servers.

H(i, d) =

0 n = d

w(d)0,i d = 0, i ≥ 1

mind−1≤j<i

(H(j, d− 1) + w(d)(j, i)

), 1 ≤ d < n

w(d)j,i =

∑i

l=j+1wl(vl − vj+1), vk =

∑k−1

j=1dj

Woeginger ’00

Page 40: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

11-1

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Examples of

i ≤ n, d ≤ D

• Length Limited Huffman Codes

w(d)(j, i) = S2j−i where Sk =∑k

i=1 pi.

• Wireless mobile paging w(d)(j, i) = i(∑i

`=j+1p`

)• D-Medians on a Directed Line w(d)(j, i) =

∑i

l=j+1wl(vl − vj+1)

Page 41: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

11-2

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Examples of

i ≤ n, d ≤ D

• Length Limited Huffman Codes

w(d)(j, i) = S2j−i where Sk =∑k

i=1 pi.

• Wireless mobile paging w(d)(j, i) = i(∑i

`=j+1p`

)• D-Medians on a Directed Line w(d)(j, i) =

∑i

l=j+1wl(vl − vj+1)

All these w(d)(j, i) = wj,i satisfy Monge property

wj,i + wj+1,i+1 ≤ wj,i+1 + wj+1,i

⇒ H(n, D) can be calculated in O(nD) time

Page 42: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

12-1

Outline

• Review of the Monge Speedup

• Maintaining the Speedup in anOnline Setting

• Saving Space While Saving Time

Page 43: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

13-1

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Given a DP in the form

in which, for fixed d, the w(d) are Monge, e.g., D-limited HuffmanEncoding, D-Median on a line or Wireless Paging , the H(·, ·) tablecan be filled in using only O(nD) time.

0 ≤ i ≤ n0 ≤ d ≤ D

Page 44: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

13-2

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Given a DP in the form

in which, for fixed d, the w(d) are Monge, e.g., D-limited HuffmanEncoding, D-Median on a line or Wireless Paging , the H(·, ·) tablecan be filled in using only O(nD) time.

0 ≤ i ≤ n0 ≤ d ≤ D

On the other hand, finding actual “solution path” of DP, correspond-ing to min-cost tree, median locations or paging schedule, requiresbacktracking through DP table. This implies storing entire table,using Θ(nD) space.

Furthermore, calculation of H(·, d) only requires knowledge ofH(·, d − 1). So, if H(n, D) is final goal, we can fill in table iter-atively, for d = 1, 2, . . . , D, using only O(n) space.

Page 45: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

14-1

Context:H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

D-Length-Limited Huffman Coding

w(d)(j, i) = S2j−i where Sk =∑k

i=1pi.(*)

Page 46: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

14-2

Context:H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

D-Length-Limited Huffman Coding

w(d)(j, i) = S2j−i where Sk =∑k

i=1pi.

Larmore & Hirschberg (’90) O(nD) time, O(n) space.

Very clever special-purpose algorithm; culmination of a longseries of papers by various authors on this problem.

(*)

Page 47: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

14-3

Context:H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

D-Length-Limited Huffman Coding

w(d)(j, i) = S2j−i where Sk =∑k

i=1pi.

Larmore & Hirschberg (’90) O(nD) time, O(n) space.

Very clever special-purpose algorithm; culmination of a longseries of papers by various authors on this problem.

(*)

Larmore & Przytycka (’91) Derived (*) DP formulation

Easy O(nD) time (Monge) algorithm but not interesting sinceit requires Θ(nD) space as well.

Page 48: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

14-4

Context:H(i, d) = min

0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

D-Length-Limited Huffman Coding

w(d)(j, i) = S2j−i where Sk =∑k

i=1pi.

Larmore & Hirschberg (’90) O(nD) time, O(n) space.

Very clever special-purpose algorithm; culmination of a longseries of papers by various authors on this problem.

(*)

Larmore & Przytycka (’91) Derived (*) DP formulation

Easy O(nD) time (Monge) algorithm but not interesting sinceit requires Θ(nD) space as well.

Would like to reduce space for (*) down to Θ(n)

Page 49: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-1

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Page 50: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-2

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

Page 51: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-3

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

Page 52: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-4

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

H(i, d) = cost of min-cost path from (0, 0) to (d, i).

Given row H(·, d − 1), SMAWK calculates row H(·, d) in O(n)time. By throwing away uneeded rows, can calculate H(·, D) inO(nD) time and O(D) space.

Page 53: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-5

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

H(i, d) = cost of min-cost path from (0, 0) to (d, i).

Given row H(·, d − 1), SMAWK calculates row H(·, d) in O(n)time. By throwing away uneeded rows, can calculate H(·, D) inO(nD) time and O(D) space.

Page 54: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-6

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

H(i, d) = cost of min-cost path from (0, 0) to (d, i).

Given row H(·, d − 1), SMAWK calculates row H(·, d) in O(n)time. By throwing away uneeded rows, can calculate H(·, D) inO(nD) time and O(D) space.

Page 55: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-7

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

H(i, d) = cost of min-cost path from (0, 0) to (d, i).

Given row H(·, d − 1), SMAWK calculates row H(·, d) in O(n)time. By throwing away uneeded rows, can calculate H(·, D) inO(nD) time and O(D) space.

Page 56: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-8

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

H(i, d) = cost of min-cost path from (0, 0) to (d, i).

Given row H(·, d − 1), SMAWK calculates row H(·, d) in O(n)time. By throwing away uneeded rows, can calculate H(·, D) inO(nD) time and O(D) space.

Page 57: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-9

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

H(i, d) = cost of min-cost path from (0, 0) to (d, i).

Given row H(·, d − 1), SMAWK calculates row H(·, d) in O(n)time. By throwing away uneeded rows, can calculate H(·, D) inO(nD) time and O(D) space.

Page 58: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

15-10

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

Alternative Interpretation:

Consider a layered graph in whichedges only go down one level and tothe right.

w(

(d− 1, j) → (d, i))

= w(d)(j, i)

H(i, d) = cost of min-cost path from (0, 0) to (d, i).

Given row H(·, d − 1), SMAWK calculates row H(·, d) in O(n)time. By throwing away uneeded rows, can calculate H(·, D) inO(nD) time and O(D) space.

On the other hand, finding optimal path to H(D,n) requireskeeping entire Θ(nD) space table to backtrack through

Page 59: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

16-1

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

We will now see how to find pathusing O(D + n) space.

Modification of idea due to

Hirschberg (’75)

Munro & Ramirez (’82)

Page 60: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

16-2

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)0 ≤ i ≤ n0 ≤ d ≤ D

We will now see how to find pathusing O(D + n) space.

Modification of idea due to

Hirschberg (’75)

Munro & Ramirez (’82)

Let y be below and to the right of x.Assume existence of an oracleMid(x, y) that returns a midpoint(hop distance) on some min-cost x-ypath.

x

y

Page 61: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-1

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

Page 62: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-2

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

We now have a simple recursive pro-cedure for building min-cost path

Buildpath(x,y)

If yd = xd+1

return (x → y)

else

z = Mid(x, y)

Buildpath(x,z)

Buildpath(z,y)

(0, 0)

(D, n)

Page 63: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-3

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

We now have a simple recursive pro-cedure for building min-cost path

Buildpath(x,y)

If yd = xd+1

return (x → y)

else

z = Mid(x, y)

Buildpath(x,z)

Buildpath(z,y)

(0, 0)

(D, n)

Page 64: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-4

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

We now have a simple recursive pro-cedure for building min-cost path

Buildpath(x,y)

If yd = xd+1

return (x → y)

else

z = Mid(x, y)

Buildpath(x,z)

Buildpath(z,y)

(0, 0)

(D, n)

Page 65: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-5

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

We now have a simple recursive pro-cedure for building min-cost path

Buildpath(x,y)

If yd = xd+1

return (x → y)

else

z = Mid(x, y)

Buildpath(x,z)

Buildpath(z,y)

(0, 0)

(D, n)

Page 66: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-6

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

We now have a simple recursive pro-cedure for building min-cost path

Buildpath(x,y)

If yd = xd+1

return (x → y)

else

z = Mid(x, y)

Buildpath(x,z)

Buildpath(z,y)

(0, 0)

(D, n)

Page 67: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-7

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

We now have a simple recursive pro-cedure for building min-cost path

Buildpath(x,y)

If yd = xd+1

return (x → y)

else

z = Mid(x, y)

Buildpath(x,z)

Buildpath(z,y)

(0, 0)

(D, n)

Page 68: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

17-8

Mid(x, y) returns a midpoint (hop distance)on some min-cost x-y path.

x

y

We now have a simple recursive pro-cedure for building min-cost path

Buildpath(x,y)

If yd = xd+1

return (x → y)

else

z = Mid(x, y)

Buildpath(x,z)

Buildpath(z,y)

(0, 0)

(D, n)

Page 69: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

18-1

Buildpath(x,y)

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Page 70: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

18-2

Buildpath(x,y)

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: If Mid(x, y) uses O(D + n) space

⇒ Buildpath(0,F) uses O(D + n) space

Page 71: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

18-3

Buildpath(x,y)

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: If Mid(x, y) uses O(D + n) space

⇒ Buildpath(0,F) uses O(D + n) space

Lemma: Let Area(x, y) be area of x, y boxx

y

If Mid(x, y) uses O(Area(x, y)) time

⇒ Buildpath(0,F) uses O(Dn) time

Page 72: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

19-1

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: Let Area(x, y) be area of x, y boxx

y

If Mid(x, y) uses O(Area(x, y)) time

⇒ Buildpath(0,F) uses O(Dn) time

Buildpath(x,y)

Page 73: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

19-2

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: Let Area(x, y) be area of x, y boxx

y

If Mid(x, y) uses O(Area(x, y)) time

⇒ Buildpath(0,F) uses O(Dn) time

Proof: Rectangles at recursion level i are height ≤ D/2i

⇒ Total work at level i is ≤ nD/2i

⇒ Total work ≤ n

(D

20+

D

21+

D

22+

D

23+ · · ·

)≤ 2nD

Buildpath(x,y)

Page 74: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

19-3

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: Let Area(x, y) be area of x, y boxx

y

If Mid(x, y) uses O(Area(x, y)) time

⇒ Buildpath(0,F) uses O(Dn) time

Proof: Rectangles at recursion level i are height ≤ D/2i

⇒ Total work at level i is ≤ nD/2i

⇒ Total work ≤ n

(D

20+

D

21+

D

22+

D

23+ · · ·

)≤ 2nD

Buildpath(x,y)

Page 75: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

19-4

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: Let Area(x, y) be area of x, y boxx

y

If Mid(x, y) uses O(Area(x, y)) time

⇒ Buildpath(0,F) uses O(Dn) time

Proof: Rectangles at recursion level i are height ≤ D/2i

⇒ Total work at level i is ≤ nD/2i

⇒ Total work ≤ n

(D

20+

D

21+

D

22+

D

23+ · · ·

)≤ 2nD

Buildpath(x,y)

Page 76: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

19-5

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: Let Area(x, y) be area of x, y boxx

y

If Mid(x, y) uses O(Area(x, y)) time

⇒ Buildpath(0,F) uses O(Dn) time

Proof: Rectangles at recursion level i are height ≤ D/2i

⇒ Total work at level i is ≤ nD/2i

⇒ Total work ≤ n

(D

20+

D

21+

D

22+

D

23+ · · ·

)≤ 2nD

Buildpath(x,y)

Page 77: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

19-6

If yd = xd+1

return (x → y)elsez = Mid(x, y)Buildpath(x,z)Buildpath(z,y)

0 = (0, 0)

F = (D, n)

Lemma: Let Area(x, y) be area of x, y boxx

y

If Mid(x, y) uses O(Area(x, y)) time

⇒ Buildpath(0,F) uses O(Dn) time

Proof: Rectangles at recursion level i are height ≤ D/2i

⇒ Total work at level i is ≤ nD/2i

⇒ Total work ≤ n

(D

20+

D

21+

D

22+

D

23+ · · ·

)≤ 2nD

Buildpath(x,y)

Page 78: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

20-1

Just saw that if Mid(x, y) can beimplemented using O(D + n) space andArea(x, y) time, then path can be built usingO(D + n) space and O(Dn) time.

x

y

There are two different methods in literature for implementingMid(x, y). They can both be used here, but we will use (b).

(a) Hirschberg (’75)

(b) Munro & Ramirez (’82)

For longest common subsequence problem.Runs two modified Dijkstra’s that meet in “middle”Every vertex had constant outdegree (≤ 3)Used extensively in bioinformatics.

For graphs like our’sRuns one modified DijkstraUses Θ(Dn2) time (we can improve to Θ(Dn) with Monge)

Page 79: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-1

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

Page 80: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-2

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

Page 81: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-3

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 82: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-4

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 83: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-5

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 84: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-6

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 85: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-7

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 86: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-8

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 87: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-9

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 88: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-10

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 89: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-11

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 90: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-12

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 91: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-13

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 92: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-14

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 93: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-15

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 94: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-16

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 95: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-17

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 96: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

21-18

Implementing Mid(x, y) in O(D + n) spaceand Area(x, y) time

x

y

x

y

For every z, let C(z) be min costpath distance from x to z.For zd ≥ d̄, let P (z) be a point onlevel d̄ lying on some min-cost path.

If zd = d̄, P (z) = z.If zd > d̄, then P (z) = P (pred(z))where pred(z) is predecessor of z onmin cost path.

All of the C(z) and P (z) on level dcan be calculated in O(yd − xd) time(Monge property) using only knowl-edge of C(z′) and P (z′) where z′ onlevel d− 1.

Page 97: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

22-1

Outline

••• Review of the Monge Speedup

• Maintaining the Speedup in anOnline Setting

• Saving Space While Saving Time

Page 98: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

23-1

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

Page 99: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

23-2

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

For any fixed d, the problem is to find the row minima of alower triangular matrix M =

{aj,i

}where

For j < i, Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

∞i

j

n

n

Page 100: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

23-3

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

For any fixed d, the problem is to find the row minima of alower triangular matrix M =

{aj,i

}where

For j < i, Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

∞i

jIf n → (n + 1) must findminimum of new row.

n

n

Page 101: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

23-4

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

For any fixed d, the problem is to find the row minima of alower triangular matrix M =

{aj,i

}where

For j < i, Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

∞i

jIf n → (n + 1) must findminimum of new row.

n

n

n+1

Page 102: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

23-5

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

For any fixed d, the problem is to find the row minima of alower triangular matrix M =

{aj,i

}where

For j < i, Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

∞i

jIf n → (n + 1) must findminimum of new row.

n

n

n+1

Context: Adding new point toright of line in D-median prob-lem requires updating median lo-cations. This requires finding“min” of new row on bottom ofMonge matrices.

Page 103: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

23-6

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

) 0 ≤ i ≤ n0 ≤ d ≤ D

For any fixed d, the problem is to find the row minima of alower triangular matrix M =

{aj,i

}where

For j < i, Mj,i = H(j, d− 1) + w(d)(j, i); else Mj,i = ∞

∞i

jIf n → (n + 1) must findminimum of new row.

n

n

n+1

SMAWK/LARSCH requirebatching queries. They do notprovide online processing (inO(1) time per step).

Page 104: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

24-1

Suppose we are given an implicitly defined lower triangularmatrix A =

{a(n, j)

}in which we want to find row minima.

h(n) = min1≤j<n a(n, j)

Page 105: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

24-2

Suppose we are given an implicitly defined lower triangularmatrix A =

{a(n, j)

}in which we want to find row minima.

a(n, j)− a(n− 1, j) = cn + δjβn,

βn ≥ 0, and δ1 ≥ δ2 ≥ δ3 · · ·.

∀1 ≤ j < n,

We say that the a(n, j) satisfy the online Monge property , if

where cn, βn and δj are constants satisfying

h(n) = min1≤j<n a(n, j)

Page 106: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

24-3

Suppose we are given an implicitly defined lower triangularmatrix A =

{a(n, j)

}in which we want to find row minima.

a(n, j)− a(n− 1, j) = cn + δjβn,

βn ≥ 0, and δ1 ≥ δ2 ≥ δ3 · · ·.

∀1 ≤ j < n,

We say that the a(n, j) satisfy the online Monge property , if

where cn, βn and δj are constants satisfying

h(n) = min1≤j<n a(n, j)

Theorem: If ∀n, i , the value of a(n, i) can be computed in O(1)time, provided that the values of h(j) for 1 ≤ j < n are known,

Page 107: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

24-4

Suppose we are given an implicitly defined lower triangularmatrix A =

{a(n, j)

}in which we want to find row minima.

a(n, j)− a(n− 1, j) = cn + δjβn,

βn ≥ 0, and δ1 ≥ δ2 ≥ δ3 · · ·.

∀1 ≤ j < n,

We say that the a(n, j) satisfy the online Monge property , if

where cn, βn and δj are constants satisfying

h(n) = min1≤j<n a(n, j)

Theorem: If ∀n, i , the value of a(n, i) can be computed in O(1)time, provided that the values of h(j) for 1 ≤ j < n are known,

⇒ The h(i) can be computed consecutively h(1), h(2), . . . usingO(1) amortized and O(log n) worst case time to calculate h(n).

Page 108: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

25-1

βn ≥ 0, δi ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Page 109: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

25-2

βn ≥ 0, δi ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Stronger than regular Monge property

a(n + 1, j) + a(n, j + 1)− a(n, j)− a(n + 1, j + 1)

= (δj − δj+1)βn+1 ≥ 0,

So Online Monge is special case of Monge

Page 110: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

25-3

βn ≥ 0, δi ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Stronger than regular Monge property

a(n + 1, j) + a(n, j + 1)− a(n, j)− a(n + 1, j + 1)

= (δj − δj+1)βn+1 ≥ 0,

If problem has this stronger property, Theorem says thatMonge speedup can be maintained in online problem variant.

So Online Monge is special case of Monge

Page 111: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

26-1

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Page 112: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

26-2

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

Page 113: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

26-3

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)

Page 114: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

26-4

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Fix d ⇒ a(i, j) = H(j, d− 1) + w(d)(j, i)

⇒ a(i, j)−a(i−1, j) = w(d)(j, i)−w(d)(j, i−1)

Page 115: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

26-5

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Fix d ⇒ a(i, j) = H(j, d− 1) + w(d)(j, i)

⇒ a(i, j)−a(i−1, j) = w(d)(j, i)−w(d)(j, i−1)

D-Medians on a Directed Line: w(d)(j, i) =∑i

l=j+1wl(vl − vj+1)

Page 116: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

26-6

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Fix d ⇒ a(i, j) = H(j, d− 1) + w(d)(j, i)

⇒ a(i, j)−a(i−1, j) = w(d)(j, i)−w(d)(j, i−1)

D-Medians on a Directed Line: w(d)(j, i) =∑i

l=j+1wl(vl − vj+1)

a(i, j)− a(i− 1, j) = wivi + (−vj+1) wi

Page 117: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

26-7

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Fix d ⇒ a(i, j) = H(j, d− 1) + w(d)(j, i)

⇒ a(i, j)−a(i−1, j) = w(d)(j, i)−w(d)(j, i−1)

D-Medians on a Directed Line: w(d)(j, i) =∑i

l=j+1wl(vl − vj+1)

a(i, j)− a(i− 1, j) = wivi + (−vj+1) wi

ci δj βi

Page 118: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

27-1

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Fix d ⇒ a(i, j) = H(j, d− 1) + w(d)(j, i)

⇒ a(i, j)−a(i−1, j) = w(d)(j, i)−w(d)(j, i−1)

Wireless Mobile Paging w(d)(j, i) = i(∑i

`=j+1p`

)

Page 119: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

27-2

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Fix d ⇒ a(i, j) = H(j, d− 1) + w(d)(j, i)

⇒ a(i, j)−a(i−1, j) = w(d)(j, i)−w(d)(j, i−1)

Wireless Mobile Paging

a(i, j)− a(i− 1, j) = ipi +

i−1∑t=j+1

pt

w(d)(j, i) = i(∑i

`=j+1p`

)

Page 120: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

27-3

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

Occurs Quite Naturally

H(i, d) = min0≤j<i

(H(j, d− 1) + w(d)(j, i)

)Fix d ⇒ a(i, j) = H(j, d− 1) + w(d)(j, i)

⇒ a(i, j)−a(i−1, j) = w(d)(j, i)−w(d)(j, i−1)

Wireless Mobile Paging

a(i, j)− a(i− 1, j) = ipi +

i−1∑t=j+1

pt

ci δj βi

w(d)(j, i) = i(∑i

`=j+1p`

)=

(ipi +

j−1∑t=1

pj

)+

(−

j∑t=1

pt

)1

Page 121: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

28-1

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

h(n) = min1≤j<n a(n, j)

Page 122: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

28-2

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

h(n) = min1≤j<n a(n, j)

∀ 1 ≤ j ≤ n ≤ N define lines and Lower Envelope

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Page 123: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

28-3

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

h(n) = min1≤j<n a(n, j)

∀ 1 ≤ j ≤ n ≤ N define lines and Lower Envelope

Lnj (x) = a(n, j) + δj · x

h(n) = min1≤j≤n

Lnj (0) = Ln(0).⇒

Ln(x) = min1≤j≤n

Lnj (x)

Page 124: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

28-4

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

h(n) = min1≤j<n a(n, j)

∀ 1 ≤ j ≤ n ≤ N define lines and Lower Envelope

Lnj (x) = a(n, j) + δj · x

h(n) = min1≤j≤n

Lnj (0) = Ln(0).⇒

Algorithm will maintain Ln(x) for x ∈ [0,∞]

Ln(x) = min1≤j≤n

Lnj (x)

Page 125: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

28-5

βn ≥ 0, δj ↓a(n, j)− a(n− 1, j) = cn + δjβn,

Online Monge:

h(n) = min1≤j<n a(n, j)

∀ 1 ≤ j ≤ n ≤ N define lines and Lower Envelope

Lnj (x) = a(n, j) + δj · x

h(n) = min1≤j≤n

Lnj (0) = Ln(0).⇒

Algorithm will maintain Ln(x) for x ∈ [0,∞]

Ln(x) = min1≤j≤n

Lnj (x)

No line can appear on lower envelope more than once,so algorithm only has to keep track of < n breakpoints.These will not change “much” from step to step

Page 126: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

29-1

• The slopes of the segments forming the lower envelope of aset of lines decreases as one sweeps from left to right. Sinceδ1 > δ2 > · · · > δn, we have z1 < z2 < · · · < zt = n

• The only data structure used is an array, called the active-indices array, Z = (z1, . . . , zt) for some t ≤ n.

• It stores, from left to right, the indices of the Lnj that

appear on Ln in the range x ∈ [0,∞).

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Page 127: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

29-2

• The slopes of the segments forming the lower envelope of aset of lines decreases as one sweeps from left to right. Sinceδ1 > δ2 > · · · > δn, we have z1 < z2 < · · · < zt = n

• The only data structure used is an array, called the active-indices array, Z = (z1, . . . , zt) for some t ≤ n.

• It stores, from left to right, the indices of the Lnj that

appear on Ln in the range x ∈ [0,∞).

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

L1

L2

L3

L4

L5

Page 128: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

29-3

• The slopes of the segments forming the lower envelope of aset of lines decreases as one sweeps from left to right. Sinceδ1 > δ2 > · · · > δn, we have z1 < z2 < · · · < zt = n

• The only data structure used is an array, called the active-indices array, Z = (z1, . . . , zt) for some t ≤ n.

• It stores, from left to right, the indices of the Lnj that

appear on Ln in the range x ∈ [0,∞).

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

L1

L2

L3

L4

L5

Page 129: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

29-4

• The slopes of the segments forming the lower envelope of aset of lines decreases as one sweeps from left to right. Sinceδ1 > δ2 > · · · > δn, we have z1 < z2 < · · · < zt = n

• The only data structure used is an array, called the active-indices array, Z = (z1, . . . , zt) for some t ≤ n.

• It stores, from left to right, the indices of the Lnj that

appear on Ln in the range x ∈ [0,∞).

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

L1

L2

L3

L4

L5

Z = (1, 2, 4, 5)

Page 130: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

30-1

To update lower envelope from n− 1 to nRecall a(n, j)− a(n− 1, j) = cn + δjβn

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Page 131: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

30-2

Lnj (x) = [a(n, j)− δj βn] + δj (x + βn)

= [a(n− 1, j) + cn] + δj (x + βn)= Ln−1

j (x + βn) + cn.

To update lower envelope from n− 1 to nRecall a(n, j)− a(n− 1, j) = cn + δjβn

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Then ∀ 1 ≤ j ≤ n− 1.

Page 132: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

30-3

Lnj (x) = [a(n, j)− δj βn] + δj (x + βn)

= [a(n− 1, j) + cn] + δj (x + βn)= Ln−1

j (x + βn) + cn.

To update lower envelope from n− 1 to nRecall a(n, j)− a(n− 1, j) = cn + δjβn

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Then ∀ 1 ≤ j ≤ n− 1.

So lower envelope for n is(a) lower envelope for n− 1 shifted vertically and to right.(b) with new line Ln

n added

Page 133: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

30-4

Lnj (x) = [a(n, j)− δj βn] + δj (x + βn)

= [a(n− 1, j) + cn] + δj (x + βn)= Ln−1

j (x + βn) + cn.

To update lower envelope from n− 1 to nRecall a(n, j)− a(n− 1, j) = cn + δjβn

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Then ∀ 1 ≤ j ≤ n− 1.

So lower envelope for n is(a) lower envelope for n− 1 shifted vertically and to right.(b) with new line Ln

n addedNote: Because δj ↓, line Ln

n must be on lower envelope,and be rightmost segment on lower envelope

Page 134: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

31-1

Lower env for linesLn−1

j (x) : 1 ≤ j < n

h(n−1) = min1≤j≤n−1

Ln−1j (0)

Page 135: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

31-2

Lower env for linesLn−1

j (x) : 1 ≤ j < n

h(n−1) = min1≤j≤n−1

Ln−1j (0)

Lower env for linesLn

j (x) = Ln−1j (x+βn)+cn

1 ≤ j < n

Page 136: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

31-3

Lower env for linesLn−1

j (x) : 1 ≤ j < n

h(n−1) = min1≤j≤n−1

Ln−1j (0)

Lower env for linesLn

j (x) = Ln−1j (x+βn)+cn

1 ≤ j < n

Note: lines shift upaxis shifts to right

Page 137: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

31-4

Lower env for linesLn−1

j (x) : 1 ≤ j < n

h(n−1) = min1≤j≤n−1

Ln−1j (0)

Lower env for linesLn

j (x) = Ln−1j (x+βn)+cn

1 ≤ j < n

Note: lines shift upaxis shifts to right

Lower env for lines

Lnj (x) : 1 ≤ j ≤ n

h(n) = min1≤j≤n

Lnj (0)

Page 138: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

32-1

While moving from

n = 7 to n = 8the indices of the active(lower envelope) lineschange from

{1, 2, 4, 5, 7}

Page 139: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

32-2

While moving from

n = 7 to n = 8the indices of the active(lower envelope) lineschange from

{1, 2, 4, 5, 7} to

{4, 5, 7}

Page 140: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

32-3

While moving from

n = 7 to n = 8the indices of the active(lower envelope) lineschange from

{1, 2, 4, 5, 7} to

{4, 5, 7} to

{4, 5, 8}

Page 141: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

32-4

While moving from

n = 7 to n = 8the indices of the active(lower envelope) lineschange from

{1, 2, 4, 5, 7} to

{4, 5, 7} to

{4, 5, 8}

We walk from leftto chop off {1, 2}

Page 142: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

32-5

While moving from

n = 7 to n = 8the indices of the active(lower envelope) lineschange from

{1, 2, 4, 5, 7} to

{4, 5, 7} to

{4, 5, 8}

We walk from leftto chop off {1, 2}

And then add 8from right, chop-ping off 7

Page 143: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

33-1

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Lower envelope for n is(a) lower envelope for n− 1 shifted vertically and to right.

Note: Because δj ↓, line Lnn must be on lower envelope,

and be rightmost segment on lower envelope

(b) with new line Lnn added

Page 144: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

33-2

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Lower envelope for n is(a) lower envelope for n− 1 shifted vertically and to right.

Note: Because δj ↓, line Lnn must be on lower envelope,

and be rightmost segment on lower envelope

(b) with new line Lnn added

Scan from left, chopping off line segments.

Page 145: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

33-3

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Lower envelope for n is(a) lower envelope for n− 1 shifted vertically and to right.

Note: Because δj ↓, line Lnn must be on lower envelope,

and be rightmost segment on lower envelope

(b) with new line Lnn added

Scan from left, chopping off line segments.

Scan from right to find line segments chopped off by Lnn

Page 146: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

33-4

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Lower envelope for n is(a) lower envelope for n− 1 shifted vertically and to right.

Note: Because δj ↓, line Lnn must be on lower envelope,

and be rightmost segment on lower envelope

(b) with new line Lnn added

Scan from left, chopping off line segments.

Scan from right to find line segments chopped off by Lnn

Total amount of work per step is O(1) + # indices cut. Once aline (index) disappears from lower envelope it never reappears.Amortizing over all lines gives O(1) cost per update.

Page 147: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

33-5

Lnj (x) = a(n, j) + δj · x Ln(x) = min

1≤j≤nLn

j (x)

Lower envelope for n is(a) lower envelope for n− 1 shifted vertically and to right.

Note: Because δj ↓, line Lnn must be on lower envelope,

and be rightmost segment on lower envelope

(b) with new line Lnn added

Scan from left, chopping off line segments.

Scan from right to find line segments chopped off by Lnn

Total amount of work per step is O(1) + # indices cut. Once aline (index) disappears from lower envelope it never reappears.Amortizing over all lines gives O(1) cost per update.

Can also use binary search to find “cut off points” in O(log n)worst case time

Page 148: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

34-1

∞i

j

n

n

We just showed that for very specialmatrices A = {ai,j} the row minimacan be found online, one row at atime, in O(1) amortized and O(log n)worst-case time per step. The re-quired condition was a very strongspecialization of the Monge property.

Page 149: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

34-2

∞i

j

n

n

n+1

We just showed that for very specialmatrices A = {ai,j} the row minimacan be found online, one row at atime, in O(1) amortized and O(log n)worst-case time per step. The re-quired condition was a very strongspecialization of the Monge property.

Page 150: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

34-3

∞i

j

n

n

n+1

We just showed that for very specialmatrices A = {ai,j} the row minimacan be found online, one row at atime, in O(1) amortized and O(log n)worst-case time per step. The re-quired condition was a very strongspecialization of the Monge property.

Open QuestionAre there weaker conditions that will permit O(1) amor-tized updates?

Page 151: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

34-4

∞i

j

n

n

n+1

We just showed that for very specialmatrices A = {ai,j} the row minimacan be found online, one row at atime, in O(1) amortized and O(log n)worst-case time per step. The re-quired condition was a very strongspecialization of the Monge property.

Open QuestionAre there weaker conditions that will permit O(1) amor-tized updates?

Can show that it’s not possible for general Monge matrix

Page 152: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

35-1

Outline

• Review of the Monge Speedup

• Maintaining the Speedup in anOnline Setting

• Saving Space While Saving Time

• Thank YouQuestions?

Page 153: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

36-1

• Two-Sided Online K-Median on a Line

w1 w2 w3 w4 wn−1 wn

d1 d2 d3 dn−1

Identify k nodes as service centers. Cost of servicing requestwi, is wi times distance from node i to nearest service center.Problem is to find location of k service centers that minimizetotal service cost.

Open Question

Page 154: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

36-2

• Two-Sided Online K-Median on a Line

w1 w2 w3 w4 wn−1 wn

d1 d2 d3 dn−1

Identify k nodes as service centers. Cost of servicing requestwi, is wi times distance from node i to nearest service center.Problem is to find location of k service centers that minimizetotal service cost.• Naive DP: O(kn2)

• Using Monge property: O(kn)

• Online, adding new element to right: Amortized O(k)

Open Question

Page 155: Revisiting The Monge Property - cse.ust.hkgolin/Talks/Revisiting_Monge.pdf · Revisiting The Monge Property Mordecai Golin Hong Kong UST Joint Work with ... down to O(n). • SMAWK

36-3

• Two-Sided Online K-Median on a Line

w1 w2 w3 w4 wn−1 wn

d1 d2 d3 dn−1

Identify k nodes as service centers. Cost of servicing requestwi, is wi times distance from node i to nearest service center.Problem is to find location of k service centers that minimizetotal service cost.• Naive DP: O(kn2)

• Using Monge property: O(kn)

• Online, adding new element to right: Amortized O(k)

Online Problem: Adding new elements to right and left.Best known is O(kn). Just as bad as reconstructing from scratch.Is there a better way?

Open Question