On Cartesian Trees, Lowest Common Ancestors, and Range Minimum - - PowerPoint PPT Presentation

on cartesian trees lowest common ancestors and range
SMART_READER_LITE
LIVE PREVIEW

On Cartesian Trees, Lowest Common Ancestors, and Range Minimum - - PowerPoint PPT Presentation

On Cartesian Trees, Lowest Common Ancestors, and Range Minimum Queries 0 2 0 4 3 5 1 7 6 1 2 min? 3 6 4 5 7 LCA? Parallel Computing Day Ben-Gurion University Tuesday, October 20, 2009 RMQ 2 0 4 3 5 1 7 6 Tuesday,


slide-1
SLIDE 1

On Cartesian Trees, Lowest Common Ancestors, and Range Minimum Queries

2 4 3 5 1 7 6

min?

2 1 3 4 5 6 7

LCA?

Parallel Computing Day Ben-Gurion University

Tuesday, October 20, 2009
slide-2
SLIDE 2

2 4 3 5 1 7 6

RMQ

Tuesday, October 20, 2009
slide-3
SLIDE 3

RMQ

2 4 3 5 1 7 6

min?

Tuesday, October 20, 2009
slide-4
SLIDE 4

RMQ

2 4 3 5 1 7 6

min?

  • Applications:
  • String Processing & Computational Biology
  • Search Engines and Document Retrieval
  • Equivalence to LCA
  • Database Queries
Tuesday, October 20, 2009
slide-5
SLIDE 5

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-6
SLIDE 6

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-7
SLIDE 7

2 1

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-8
SLIDE 8

2 1 3 4 5 6 7

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-9
SLIDE 9

2 4 3 5 1 7 6

min?

2 1 3 4 5 6 7

RMQ & Cartesian Trees

LCA?

Tuesday, October 20, 2009
slide-10
SLIDE 10

2 4 3 5 1 7 6

min?

2 1 3 4 5 6 7

RMQ & Cartesian Trees

LCA? O(n) [Gabow, Bentley, Tarjan 1984]

Tuesday, October 20, 2009
slide-11
SLIDE 11

2 3 4 5

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-12
SLIDE 12

2 3 4 5 1

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-13
SLIDE 13

2 3 4 5 1

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-14
SLIDE 14

2 3 4 5 1

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-15
SLIDE 15

2 3 4 5 1

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-16
SLIDE 16

2 3 4 5 1

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-17
SLIDE 17

2 4 5 3 1

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-18
SLIDE 18

2 4 5 3 1

O(n) [Gabow, Bentley, Tarjan 1984]

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-19
SLIDE 19

1

O(n) [Gabow, Bentley, Tarjan 1984]

2 4 5 3 6 7

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-20
SLIDE 20

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n) [Gabow, Bentley, Tarjan 1984]

2 4 5 3 6 7

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-21
SLIDE 21

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n) [Gabow, Bentley, Tarjan 1984]

[Schieber, Vishkin 1988] [Berkman, Vishkin 1993] [Bender et al. 2005] [Fischer, Heun 2006]

2 4 5 3 6 7

RMQ & Cartesian Trees

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-22
SLIDE 22

RMQ & Cartesian Trees

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n)

[Schieber, Vishkin 1988] [Berkman, Vishkin 1993] [Bender et al. 2005] [Fischer, Heun 2006]

2 4 5 3 6 7

{

Tuesday, October 20, 2009
slide-23
SLIDE 23

RMQ & Cartesian Trees

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n)

[Schieber, Vishkin 1988] [Berkman, Vishkin 1993] [Bender et al. 2005] [Fischer, Heun 2006]

2 4 5 3 6 7

{

0 2 0 1 3 4 3 5 3 1 6 7 6 1 0

Tuesday, October 20, 2009
slide-24
SLIDE 24

RMQ & Cartesian Trees

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n)

[Schieber, Vishkin 1988] [Berkman, Vishkin 1993] [Bender et al. 2005] [Fischer, Heun 2006]

2 4 5 3 6 7

{

0 2 0 1 3 4 3 5 3 1 6 7 6 1 0

Tuesday, October 20, 2009
slide-25
SLIDE 25

RMQ & Cartesian Trees

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n)

[Schieber, Vishkin 1988] [Berkman, Vishkin 1993] [Bender et al. 2005] [Fischer, Heun 2006]

2 4 5 3 6 7

{

0 1 0 1 2 3 2 3 2 1 2 3 2 1 0 0 2 0 1 3 4 3 5 3 1 6 7 6 1 0

Tuesday, October 20, 2009
slide-26
SLIDE 26

RMQ & Cartesian Trees

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n)

[Schieber, Vishkin 1988] [Berkman, Vishkin 1993] [Bender et al. 2005] [Fischer, Heun 2006]

2 4 5 3 6 7

{

0 1 0 1 2 3 2 3 2 1 2 3 2 1 0 0 2 0 1 3 4 3 5 3 1 6 7 6 1 0

Tuesday, October 20, 2009
slide-27
SLIDE 27

RMQ & Cartesian Trees

1

LCA: O(n) prep. O(1) query [Harel, Tarjan 1984] O(n)

[Schieber, Vishkin 1988] [Berkman, Vishkin 1993] [Bender et al. 2005] [Fischer, Heun 2006]

2 4 5 3 6 7

{

min?

0 1 0 1 2 3 2 3 2 1 2 3 2 1 0 0 2 0 1 3 4 3 5 3 1 6 7 6 1 0 0 1 0 1 2 3 2 3 2 1 2 3 2 1 0

Tuesday, October 20, 2009
slide-28
SLIDE 28

RMQ

  • Warmup: O(n log n) prep. O(1) query:

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

Tuesday, October 20, 2009
slide-29
SLIDE 29
  • Warmup: O(n log n) prep. O(1) query:
  • Compute min of every interval I s.t | I | is a power of two

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

RMQ

Tuesday, October 20, 2009
slide-30
SLIDE 30
  • Warmup: O(n log n) prep. O(1) query:
  • Compute min of every interval I s.t | I | is a power of two

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

min = 3

RMQ

Tuesday, October 20, 2009
slide-31
SLIDE 31
  • Warmup: O(n log n) prep. O(1) query:
  • Compute min of every interval I s.t | I | is a power of two

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

min = 3 min = 1

RMQ

Tuesday, October 20, 2009
slide-32
SLIDE 32
  • Warmup: O(n log n) prep. O(1) query:
  • Compute min of every interval I s.t | I | is a power of two
  • Query is composed of two overlapping intervals

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

min?

RMQ

Tuesday, October 20, 2009
slide-33
SLIDE 33
  • Warmup: O(n log n) prep. O(1) query:
  • Compute min of every interval I s.t | I | is a power of two
  • Query is composed of two overlapping intervals

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

min?

RMQ

Tuesday, October 20, 2009
slide-34
SLIDE 34

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

RMQ

Tuesday, October 20, 2009
slide-35
SLIDE 35

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

¼ log n ¼ log n ¼ log n ¼ log n

RMQ

Tuesday, October 20, 2009
slide-36
SLIDE 36

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

¼ log n ¼ log n ¼ log n ¼ log n

RMQ

Tuesday, October 20, 2009
slide-37
SLIDE 37

¼ log n ¼ log n ¼ log n ¼ log n

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

min?

RMQ

Tuesday, October 20, 2009
slide-38
SLIDE 38

¼ log n ¼ log n ¼ log n ¼ log n

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

min?

RMQ

Tuesday, October 20, 2009
slide-39
SLIDE 39

¼ log n ¼ log n ¼ log n ¼ log n

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

min?

RMQ

Tuesday, October 20, 2009
slide-40
SLIDE 40
  • RMQ LCA RMQ 1

RMQ 1

¼ log n ¼ log n ¼ log n ¼ log n

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Tuesday, October 20, 2009
slide-41
SLIDE 41
  • RMQ LCA RMQ 1

RMQ 1

  • # different Blocks = # different 1 vectors = 2¼ log n = n¼
  • Lookup table

¼ log n ¼ log n ¼ log n ¼ log n

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Tuesday, October 20, 2009
slide-42
SLIDE 42

Recursive Solution

¼ log n ¼ log n ¼ log n ¼ log n

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

  • Use the “Warmup” solution on each block
Tuesday, October 20, 2009
slide-43
SLIDE 43

Recursive Solution

¼ log n ¼ log n ¼ log n ¼ log n

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

{

  • Use the “Warmup” solution on each block
Tuesday, October 20, 2009
slide-44
SLIDE 44

Recursive Solution

¼ log n ¼ log n ¼ log n ¼ log n

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

{

O(log n loglog n) prep.

  • Use the “Warmup” solution on each block
Tuesday, October 20, 2009
slide-45
SLIDE 45

Recursive Solution

¼ log n ¼ log n ¼ log n ¼ log n

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

{

O(log n loglog n) prep.

  • Use the “Warmup” solution on each block
  • O(n loglog n) prep. O(1) query
Tuesday, October 20, 2009
slide-46
SLIDE 46
  • Use the “Warmup” solution on each block
  • O(n loglog n) prep. O(1) query
  • O(n logloglog n) prep. O(1) query

Recursive Solution

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

¼ log n ¼ log n ¼ log n ¼ log n

Tuesday, October 20, 2009
slide-47
SLIDE 47
  • Use the “Warmup” solution on each block
  • O(n loglog n) prep. O(1) query
  • O(n logloglog n) prep. O(1) query
  • O(n αk(n)) prep. O(k) query [Alon&Schieber 1987, Chazelle&Rosenberg 1989]

Recursive Solution

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

¼ log n ¼ log n ¼ log n ¼ log n

Tuesday, October 20, 2009
slide-48
SLIDE 48
  • Use the “Warmup” solution on each block
  • O(n loglog n) prep. O(1) query
  • O(n logloglog n) prep. O(1) query
  • O(n αk(n)) prep. O(k) query [Alon&Schieber 1987, Chazelle&Rosenberg 1989]
  • Why?
  • MIN any semiring operation
  • RMQ generalizations
  • Parallel Computing

Recursive Solution

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

¼ log n ¼ log n ¼ log n ¼ log n

Tuesday, October 20, 2009
slide-49
SLIDE 49

Parallel RMQ

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-50
SLIDE 50

Parallel RMQ

  • Min of n elements in O(1) time using n2 processors [Valiant 1975]

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-51
SLIDE 51

Parallel RMQ

  • Min of n elements in O(1) time using n2 processors [Valiant 1975]
  • O(1) RMQ using n4 processors

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-52
SLIDE 52

Parallel RMQ

  • Min of n elements in O(1) time using n2 processors [Valiant 1975]
  • O(1) RMQ using n4 processors
  • O(1) RMQ using n2.5 processors

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

√n √n √n √n

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-53
SLIDE 53

Parallel RMQ

  • Min of n elements in O(1) time using n2 processors [Valiant 1975]
  • O(1) RMQ using n4 processors
  • O(1) RMQ using n2.5 processors
  • O(1/ε) RMQ using n1+ε processors

1 2 1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

√n √n √n √n

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-54
SLIDE 54

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-55
SLIDE 55
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-56
SLIDE 56
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-57
SLIDE 57
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-58
SLIDE 58
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-59
SLIDE 59
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-60
SLIDE 60
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-61
SLIDE 61
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

  • n log3 n processors, O(1) time, O(1) query

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-62
SLIDE 62
  • Min of n integers each between 1 and n

in O(1) time using n processors [Fich, Ragde and Wigderson 1984]

  • n log3 n processors, O(1) time, O(1) query
  • n αk(n) processors, O(k) time, O(k) query

1 1 2 3 2 1 1 2 1 2 3 4 5 4 3 2 3 4

Parallel RMQ 1

[Berkman and Vishkin 1993]

Tuesday, October 20, 2009
slide-63
SLIDE 63
  • RMQ LCA RMQ 1

Problems with RMQ 1

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

Tuesday, October 20, 2009
slide-64
SLIDE 64
  • RMQ LCA RMQ 1
  • inefficient in parallel
  • inefficient in terms of cache-misses (can’t be done via scans)

Problems with RMQ 1

2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

Tuesday, October 20, 2009
slide-65
SLIDE 65
  • RMQ LCA RMQ 1
  • inefficient in parallel
  • inefficient in terms of cache-misses (can’t be done via scans)
  • # different Blocks = # different Cartesian trees = 4¼ log n =

[Fischer, Heun 2006]

Problems with RMQ 1

√n

¼ log n ¼ log n ¼ log n ¼ log n

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

Tuesday, October 20, 2009
slide-66
SLIDE 66
  • RMQ LCA RMQ 1
  • inefficient in parallel
  • inefficient in terms of cache-misses (can’t be done via scans)
  • # different Blocks = # different Cartesian trees = 4¼ log n =

[Fischer, Heun 2006]

  • Lookup table: index, construct

Problems with RMQ 1

√n

¼ log n ¼ log n ¼ log n ¼ log n

1 2 2 4 3 5 4 7 5 6 1 4 8 6 7 3 4 2 5 4

Tuesday, October 20, 2009
slide-67
SLIDE 67

Cache-Oblivious RMQ

  • An optimal RMQ solution that only makes sequential scans

O(n) prep. O(1) query (serial algorithm)

[Demaine, Landau and W. 2009]

Tuesday, October 20, 2009
slide-68
SLIDE 68

A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6

Tuesday, October 20, 2009
slide-69
SLIDE 69

A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6 2 1 3 4 5 6 7

Tuesday, October 20, 2009
slide-70
SLIDE 70

A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6 2 1 3 4 5 6 7

  • cache-oblivious stack holds rightmost path
Tuesday, October 20, 2009
slide-71
SLIDE 71

A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6 2 1 3 4 5 6 7

  • cache-oblivious stack holds rightmost path
  • when we climb (pop) i vertices, concatenate 0111 11

...

{

i

Tuesday, October 20, 2009
slide-72
SLIDE 72
  • cache-oblivious stack holds rightmost path
  • when we climb (pop) i vertices, concatenate 0111 11

A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6 2 1 3 4 5 6 7

...

{

i

011 1011 1011 1011 1 ... ... ... ...

{

i1

{

i2

{

i3

{

i4

Tuesday, October 20, 2009
slide-73
SLIDE 73
  • cache-oblivious stack holds rightmost path
  • when we climb (pop) i vertices, concatenate 0111 11

[ ]

A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6 2 1 3 4 5 6 7

...

{

i

011 1011 1011 1011 1 ... ... ... ...

{

i1

{

i2

{

i3

{

i4 ∈

√n

Tuesday, October 20, 2009
slide-74
SLIDE 74
  • cache-oblivious stack holds rightmost path
  • when we climb (pop) i vertices, concatenate 0111 11

{ A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6 2 1 3 4 5 6 7

...

{

i

011 1011 1011 1011 1

i1 i2

{

i3

{

i4 ∈

√n

  • ∀ binary string and ∀ query:

min?

{

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

[ ]

Tuesday, October 20, 2009
slide-75
SLIDE 75
  • cache-oblivious stack holds rightmost path
  • when we climb (pop) i vertices, concatenate 0111 11

{

011⋄⋄⋄1011⋄⋄⋄1011⋄⋄⋄1011⋄⋄⋄1

A Cache-Oblivious Cartesian Tree

¼ log n

2 4 3 5 1 7 6 2 1 3 4 5 6 7

...

{

i i1 i2

{

i3

{

i4 ∈

√n

  • ∀ binary string and ∀ query:

min?

{

[ ]

Tuesday, October 20, 2009
slide-76
SLIDE 76

RMQ Generalization I: A Cartesian Tree of a Tree

[Demaine, Landau and W. 2009]

Tuesday, October 20, 2009
slide-77
SLIDE 77

RMQ Generalization I: A Cartesian Tree of a Tree

  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
Tuesday, October 20, 2009
slide-78
SLIDE 78

RMQ Generalization I: A Cartesian Tree of a Tree

  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

Tuesday, October 20, 2009
slide-79
SLIDE 79

RMQ Generalization I: A Cartesian Tree of a Tree

  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

Tuesday, October 20, 2009
slide-80
SLIDE 80

2

RMQ Generalization I: A Cartesian Tree of a Tree

  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

6 3 5 1 6 3

Tuesday, October 20, 2009
slide-81
SLIDE 81

2

RMQ Generalization I: A Cartesian Tree of a Tree

  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

6 3 5 1 6 3

u v

Tuesday, October 20, 2009
slide-82
SLIDE 82

2

RMQ Generalization I: A Cartesian Tree of a Tree

  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

6 3 5 1 6 3

u v

Tuesday, October 20, 2009
slide-83
SLIDE 83
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3

u v

Tuesday, October 20, 2009
slide-84
SLIDE 84
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3

u v

5

Tuesday, October 20, 2009
slide-85
SLIDE 85
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3

u v

5 6

Tuesday, October 20, 2009
slide-86
SLIDE 86
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v along

any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

O(n αk(n)) prep. O(k) query [Alon and Schieber 1987]

Ω(n αk(n)) prep. for O(k) query [Pettie 2002]

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3

Tuesday, October 20, 2009
slide-87
SLIDE 87
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3

Tuesday, October 20, 2009
slide-88
SLIDE 88
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1

Tuesday, October 20, 2009
slide-89
SLIDE 89
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-90
SLIDE 90
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-91
SLIDE 91
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-92
SLIDE 92
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-93
SLIDE 93
  • The Bottleneck Edge Query problem (RMQ on graphs\trees):
  • preprocess an edge-weighted graph
  • query asks for max flow that can be routed between u,v

along any simple path

  • Undirected graphs: solve problem on the Maximum Spanning

Tree [Hu 1961]

  • The Minimum Spanning Tree Verification problem

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-94
SLIDE 94
  • Construct Cartesian tree of an input tree in O(n + sort(edges))

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-95
SLIDE 95
  • Construct Cartesian tree of an input tree in O(n + sort(edges))
  • Tight lower bound

2

RMQ Generalization I: A Cartesian Tree of a Tree

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-96
SLIDE 96
  • Construct Cartesian tree of an input tree in O(n + sort(edges))
  • Tight lower bound

2

RMQ Generalization I: Compared to AlonSchieber

6 3 5 1 6 3 1 1

Tuesday, October 20, 2009
slide-97
SLIDE 97
  • Construct Cartesian tree of an input tree in O(n + sort(edges))
  • Tight lower bound

2

RMQ Generalization I: Compared to AlonSchieber

6 3 5 1 6 3 1 1

  • Linear-time if edge-weights are sorted or integers
Tuesday, October 20, 2009
slide-98
SLIDE 98
  • Construct Cartesian tree of an input tree in O(n + sort(edges))
  • Tight lower bound

2

RMQ Generalization I: Compared to AlonSchieber

6 3 5 1 6 3 1 1

  • Linear-time if edge-weights are sorted or integers
  • Otherwise we get linear-space, O(n log[k] n) prep. O(k) query
Tuesday, October 20, 2009
slide-99
SLIDE 99
  • Construct Cartesian tree of an input tree in O(n + sort(edges))
  • Tight lower bound

2

RMQ Generalization I: Compared to AlonSchieber

6 3 5 1 6 3 1 1

  • Linear-time if edge-weights are sorted or integers
  • Otherwise we get linear-space, O(n log[k] n) prep. O(k) query
  • Maintain dynamic Cartesian tree and LCA info
Tuesday, October 20, 2009
slide-100
SLIDE 100
  • Construct Cartesian tree of an input tree in O(n + sort(edges))
  • Tight lower bound

2

RMQ Generalization I: Compared to AlonSchieber

6 3 5 1 6 3 1 1

  • Linear-time if edge-weights are sorted or integers
  • Otherwise we get linear-space, O(n log[k] n) prep. O(k) query
  • Maintain dynamic Cartesian tree and LCA info
  • Distributed: LCA labeling of the Cartesian tree
Tuesday, October 20, 2009
slide-101
SLIDE 101

RMQ Generalization II: 2D Cartesian Tree

[Demaine, Landau and W. 2009]

Tuesday, October 20, 2009
slide-102
SLIDE 102

RMQ Generalization II: 2D Cartesian Tree

  • The 2D-RMQ problem:
Tuesday, October 20, 2009
slide-103
SLIDE 103

RMQ Generalization II: 2D Cartesian Tree

  • The 2D-RMQ problem:

2 4 3 1 9 3 3 7 3 4 3 5 7 6 2 3 8 5 6 4 4 4 7 4 3 5 8 8 6 2 8 1 8 5 1 7 6 2 4 3 5 5 7 6

Tuesday, October 20, 2009
slide-104
SLIDE 104

RMQ Generalization II: 2D Cartesian Tree

  • The 2D-RMQ problem:

2 4 3 1 9 3 3 7 3 4 3 5 7 6 2 3 8 5 6 4 4 4 7 4 3 5 8 8 6 2 8 1 8 5 1 7 6 2 4 3 5 5 7 6

Tuesday, October 20, 2009
slide-105
SLIDE 105
  • The 2D-RMQ problem:
  • O(n2 log n) prep. O(log n) query [Gabow, Bentley,Tarjan 1984]
  • O(n2
αk(n)2) prep. O(k) query [Chazelle, Rosenberg 1989]
  • O(n2 log[k] n) prep, O(n2) space, O(k) query [Amir, Fischer,

Lewenstein 2007]

RMQ Generalization II: 2D Cartesian Tree

2 4 3 1 9 3 3 7 3 4 3 5 7 6 2 3 8 5 6 4 4 4 7 4 3 5 8 8 6 2 8 1 8 5 1 7 6 2 4 3 5 5 7 6

Tuesday, October 20, 2009
slide-106
SLIDE 106
  • The 2D-RMQ problem:
  • O(n2 log n) prep. O(log n) query [Gabow, Bentley,Tarjan 1984]
  • O(n2
αk(n)2) prep. O(k) query [Chazelle, Rosenberg 1989]
  • O(n2 log[k] n) prep, O(n2) space, O(k) query [Amir, Fischer,

Lewenstein 2007]

RMQ Generalization II: 2D Cartesian Tree

No 2D Cartesian tree: # different 2D-RMQ matrices ≈ n2!

2 4 3 1 9 3 3 7 3 4 3 5 7 6 2 3 8 5 6 4 4 4 7 4 3 5 8 8 6 2 8 1 8 5 1 7 6 2 4 3 5 5 7 6

Tuesday, October 20, 2009
slide-107
SLIDE 107
  • The 2D-RMQ problem:
  • O(n2 log n) prep. O(log n) query [Gabow, Bentley,Tarjan 1984]
  • O(n2
αk(n)2) prep. O(k) query [Chazelle, Rosenberg 1989]
  • O(n2 log[k] n) prep, O(n2) space, O(k) query [Amir, Fischer,

Lewenstein 2007]

  • O(n2) prep. O(1) query [Yuan, Atallah 2010]
  • RMQ Generalization II:

2D Cartesian Tree

No 2D Cartesian tree: # different 2D-RMQ matrices ≈ n2!

2 4 3 1 9 3 3 7 3 4 3 5 7 6 2 3 8 5 6 4 4 4 7 4 3 5 8 8 6 2 8 1 8 5 1 7 6 2 4 3 5 5 7 6

Tuesday, October 20, 2009
slide-108
SLIDE 108

Thank You!

Tuesday, October 20, 2009