A Fast Algorithm for Permutation Pattern Matching Based on - - PowerPoint PPT Presentation

a fast algorithm for permutation pattern matching based
SMART_READER_LITE
LIVE PREVIEW

A Fast Algorithm for Permutation Pattern Matching Based on - - PowerPoint PPT Presentation

A Fast Algorithm for Permutation Pattern Matching Based on Alternating Runs Marie-Louise Bruner (Joint work with Martin Lackner) Vienna University of Technology June 13, 2012 Permutation Patterns, Glasgow Marie-Louise Bruner A Fast Algorithm


slide-1
SLIDE 1

A Fast Algorithm for Permutation Pattern Matching Based on Alternating Runs

Marie-Louise Bruner

(Joint work with Martin Lackner)

Vienna University of Technology

June 13, 2012 Permutation Patterns, Glasgow

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 1

slide-2
SLIDE 2

Permutation Pattern Matching

Permutation Pattern Matching (PPM) Instance: A permutation T of length n (the text) and a permutation P of length k ≤ n (the pattern). Question: Is there a matching of P into T?

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 2

slide-3
SLIDE 3

Permutation Pattern Matching

Permutation Pattern Matching (PPM) Instance: A permutation T of length n (the text) and a permutation P of length k ≤ n (the pattern). Question: Is there a matching of P into T? Is there an algorithm that runs faster than exponential time?

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 2

slide-4
SLIDE 4

PPM is NP-complete

1993 (Bose, Buss, Lubiw): PPM is in general NP-complete.

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 3

slide-5
SLIDE 5

PPM is NP-complete

1993 (Bose, Buss, Lubiw): PPM is in general NP-complete. ⇒ unless P = NP, PPM cannot be solved in polynomial time

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 3

slide-6
SLIDE 6

Tractable cases of PPM

◮ Pattern avoids both 3142 and 2413

O(kn4)

◮ P = 12 . . . k or P = k . . . 21

O(n log log n)

◮ P has length at most 4

O(n log n)

◮ Pattern and Text avoid 321

O(k2n6)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 4

slide-7
SLIDE 7

The general case Anything better than the O∗(2n) runtime of brute-force search?

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 5

slide-8
SLIDE 8

Parameterized Complexity Theory

Idea: confine the combinatorial explosion to a parameter of the input

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 6

slide-9
SLIDE 9

Parameterized Complexity Theory

Idea: confine the combinatorial explosion to a parameter of the input Parameterized Problem: L ⊆ Σ∗ × N

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 6

slide-10
SLIDE 10

Parameterized Complexity Theory

Idea: confine the combinatorial explosion to a parameter of the input Parameterized Problem: L ⊆ Σ∗ × N

Fixed-parameter tractability

A parameterized problem L is fixed-parameter tractable if there is a computable function f and an integer c such that there is an algorithm solving L in time O(f (p) · |I|c).

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 6

slide-11
SLIDE 11

Alternating runs

1 8 12 4 7 11 6 3 2 9 5 10

1 8 12 (up), 4 (down), 7 11 (up), 6 3 2 (down), 9 (up), 5 (down), 10 (up)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 7

slide-12
SLIDE 12

Alternating runs

1 8 12 4 7 11 6 3 2 9 5 10

1 8 12 (up), 4 (down), 7 11 (up), 6 3 2 (down), 9 (up), 5 (down), 10 (up)

Notation

run(π)...the number of alternating runs in π, r(i) = j if i lies in the j-th run

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 7

slide-13
SLIDE 13

The alternating run algorithm

◮ Matching functions:

Reduce the search space

◮ Dynamic programming algorithm:

Checks for every matching function whether there is a compatible matching

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 8

slide-14
SLIDE 14

Matching functions

Pattern P ↓ matching function ↓ Text T

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 9

slide-15
SLIDE 15

Matching functions - an example

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 10

slide-16
SLIDE 16

Matching functions - an example

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(1) F(2) F(3)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 10

slide-17
SLIDE 17

The algorithm - finding a matching

The dynamic programming algorithm - Part 1

X0 := {(0, . . . , 0)}. For every κ ∈ [k] the data structure Xκ is recursively

  • constructed. For x ∈ Xκ−1 we search for ν ∈ [n] satisfying:

◮ ν ∈ F(r(κ)) ◮ Among all elements that are larger than xr(κ−1) and on the correct

side of xr(κ), ν has to be a valley.

◮ If κ is not the largest element in its run in P, there has to be another

larger element in F(r(κ)) lying to the right (resp. left) of ν if κ lies in a run up (resp. down). Place xν := (x1, . . . , xr(κ)−1, ν, xr(κ)+1, . . . , xrun(P)) in X ′

κ.

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 11

slide-18
SLIDE 18

The algorithm - finding a matching

The dynamic programming algorithm - Part 1

X ′

κ still consists of too many elements. In order to obtain the desired

runtime bounds, we apply the following rules:

◮ We call a vale a subsequence of T consisting of a consecutive run

down and up. If the entries of xν and yµ all lie within the same vales, it is sufficient to keep one of the two.

◮ If κ is the largest element in its run in P, it is enough to keep one

choice for every x in Xκ−1. The remaining xν’s then form Xκ.

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 12

slide-19
SLIDE 19

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(2)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-20
SLIDE 20

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(2)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-21
SLIDE 21

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(1)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-22
SLIDE 22

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(1)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-23
SLIDE 23

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(1)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-24
SLIDE 24

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(1)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-25
SLIDE 25

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(1)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-26
SLIDE 26

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(3)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-27
SLIDE 27

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(3)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-28
SLIDE 28

The algorithm - finding a matching

Pattern P Text T

2 3 1 4 1 8 12 4 7 11 6 3 2 9 5 10

F(3)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 13

slide-29
SLIDE 29

Runtime

Matching functions: √ 2

run(T)

Dynamic programming algorithm: O∗(1.2611run(T))

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 14

slide-30
SLIDE 30

Runtime

Matching functions: √ 2

run(T)

Dynamic programming algorithm: O∗(1.2611run(T)) In total: O∗(1.784run(T))

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 14

slide-31
SLIDE 31

Runtime

Matching functions: √ 2

run(T)

Dynamic programming algorithm: O∗(1.2611run(T)) In total: O∗(1.784run(T)) → This is a fixed-parameter tractable (FPT) algorithm, i.e. a runtime of f (k) · nc.

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 14

slide-32
SLIDE 32

Runtime

Matching functions: √ 2

run(T)

Dynamic programming algorithm: O∗(1.2611run(T)) In total: O∗(1.784run(T)) → This is a fixed-parameter tractable (FPT) algorithm, i.e. a runtime of f (k) · nc. Since run(T) ≤ n, we also obtain O∗(1.784n)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 14

slide-33
SLIDE 33

Alternating runs in the pattern run(P)

O∗(1.784run(T)) FPT, i.e. f (k) · nc O∗

n2 2run(P)

run(P) XP, i.e. nf (k)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 15

slide-34
SLIDE 34

Alternating runs in the pattern run(P)

O∗(1.784run(T)) FPT, i.e. f (k) · nc O∗

n2 2run(P)

run(P) XP, i.e. nf (k) no FPT result possible (W[1]-hardness)

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 15

slide-35
SLIDE 35

Conclusion

What have we done?

We found

◮ a fast algorithm for the parameter run(T), ◮ a slow algorithm for the parameter run(P).

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 16

slide-36
SLIDE 36

Conclusion

What have we done?

We found

◮ a fast algorithm for the parameter run(T), ◮ a slow algorithm for the parameter run(P).

Future work

◮ PPM parameterized by some other parameter of P? By k = run(P)?

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 16

slide-37
SLIDE 37

Conclusion

What have we done?

We found

◮ a fast algorithm for the parameter run(T), ◮ a slow algorithm for the parameter run(P).

Future work

◮ PPM parameterized by some other parameter of P? By k = run(P)? ◮ Other permutation statistics in the text?

Marie-Louise Bruner A Fast Algorithm for PPM June 13, 2012 16