• Nem Talált Eredményt

Finding small patterns in permutations in linear time

N/A
N/A
Protected

Academic year: 2022

Ossza meg "Finding small patterns in permutations in linear time"

Copied!
44
0
0

Teljes szövegt

(1)

Finding small patterns in permutations in linear time

Sylvain Guillemot Dániel Marx

Institute for Computer Science and Control Hungarian Academy of Sciences (MTA SZTAKI)

Budapest, Hungary

SODA 2014 January 5, 2014

Portland, OR

(2)

Different interpretations:

Bijective mapping σ: [n]→[n]:

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8 Ordering of [n]:

3 2 7 8 4 6 1 5 n points in the plane “in general position”:

(3)

Subpermutations

There is a natural way of defining the meaning ofσ being a subpermutation ofπ (or a “permutation pattern” in π).

Example:

σ π

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

is a subpermutation of

(4)

There is a natural way of defining the meaning ofσ being a subpermutation ofπ (or a “permutation pattern” in π).

Example:

σ π

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

is a subpermutation of

(5)

Excluding subpermutations

There aren!permutations of lengthn, but their number is much smaller if we exclude a fixed permutation:

Theorem[Marcus and Tardos 2004]

For every fixed permutationσ, the number of permutations of lengthn avoidingσ is at most cn for some constant c depending onσ.

Example:

The number of permutations of lengthn avoiding231 is exactly the Catalan numberCn= n+11 2nn

<4n.

(6)

Finding patterns in permutations

Permutation Pattern

Input: Two permutationsσ andπ.

Decide: Isσ a subpattern ofπ?

NP-hard in general [Bose, Buss, and Lubiw 1998].

Can be solved in time n`+O(1) by brute force, where`=|σ|

andn=|π|.

Can be solved in time n0.47`+o(`) [Ahal and Rabinovich 2008].

Theorem

Permutation Patterncan be solved in time 2O(`2log`)·n, where`=|σ|andn =|π|.

(7)

Finding patterns in permutations

Permutation Pattern

Input: Two permutationsσ andπ.

Decide: Isσ a subpattern ofπ?

NP-hard in general [Bose, Buss, and Lubiw 1998].

Can be solved in time n`+O(1) by brute force, where`=|σ|

andn=|π|.

Can be solved in time n0.47`+o(`) [Ahal and Rabinovich 2008]. Main result:

Theorem

can be solved in time 2O(`2log`)·n,

(8)

We define the notion of d-wide decompositionand solve the problem using the following win/win strategy:

(`=|σ|,n =|π|)

1 There is an algorithm that either findsσinπor

finds a2O(`log`)-wide decomposition ofπ.

2 There is an algorithm that, given σ and ad-wide

decomposition ofπ, decides ifσ is a subpattern ofπ in time (d`)O(`)·n.

These two algorithms together give a2O(`2log`)·n time algorithm forPermutation Pattern.

(9)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

1 2

3 4

5 6

7 8

(3,4) (9,12)

(1,2)

→10

(13,11)

→14

(6,7)

→11

(10,14)

→15

(5,8)

→12

(10)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

1 2

3 4

5 6

7 8

(3,4)

→9 (9,12) (1,2)

→10

(13,11)

→14

(6,7)

→11

(10,14)

→15

(5,8)

→12

(11)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

1 2

5 6

7 9

8

(3,4)→9

(9,12) (1,2)

→10

(13,11)

→14

(6,7)

→11

(10,14)

→15

(5,8)

→12

(12)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

1 2

5 6

7 9

8

(3,4)→9

(9,12)

(1,2)

→10 (13,11)

→14

(6,7)

→11

(10,14)

→15

(5,8)

→12

(13)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

5 6

7 10

9

8

(3,4)→9

(9,12)

(1,2)→10

(13,11)

→14

(6,7)

→11

(10,14)

→15

(5,8)

→12

(14)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

5 6

7 10

9

8

(3,4)→9

(9,12)

(1,2)→10

(13,11)

→14

(6,7)

→11 (10,14)

→15

(5,8)

→12

(15)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

5 10

9

11 8

(3,4)→9

(9,12)

(1,2)→10

(13,11)

→14

(6,7)→11

(10,14)

→15

(5,8)

→12

(16)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

5 10

9

11 8

(3,4)→9

(9,12)

(1,2)→10

(13,11)

→14

(6,7)→11

(10,14)

→15

(5,8)

→12

(17)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

10 9

11 12

(3,4)→9

(9,12)

(1,2)→10

(13,11)

→14

(6,7)→11

(10,14)

→15

(18)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

10 9

11 12

(3,4)→9 (9,12)

→13

(1,2)→10

(13,11)

(6,7)→11

(10,14)

→15

(5,8)→12

(19)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

10

11 13

(3,4)→9 (9,12)→13 (1,2)→10

(13,11)

(6,7)→11

(10,14)

→15

(20)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

10

11 13

(3,4)→9 (9,12)→13 (1,2)→10 (13,11)

→14

(6,7)→11

(10,14)

(5,8)→12

(21)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

10

14

(3,4)→9 (9,12)→13 (1,2)→10 (13,11)→14 (6,7)→11

(10,14)

15

(22)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

10

14

(3,4)→9 (9,12)→13 (1,2)→10 (13,11)→14 (6,7)→11 (10,14) (5,8)→12

(23)

Decompositions

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

15

(3,4)→9 (9,12)→13 (1,2)→10 (13,11)→14 (6,7)→11 (10,14)→15

(24)

Starting with a set of points (degenerate rectangles), the

decomposition is a sequence of merges, where a merge consists of replacing two rectangles with their bounding box:

15

R1 sees R2 horizontally (resp., vertically) if there is a horizontal (resp., vertical) line intersecting both.

A rectangle family isd-wideif every rectangle sees less than d other rectangles horizontally and less thand other rectangles vertically.

(25)

Grids

r×r-grid: partitioning the rows and the columns into r classes such that every cell contains a point.

Observation: If a point set has an r×r-grid, then it contains every permutation of lengthr.

(26)

Finding decompositions

Large grids imply large width:

Fact

Ifπ contains anr×r-grid, then every decomposition of π is Ω(r)-wide.

Large width implies large grids:

Theorem

There is anO(n) time algorithm that finds either an r×r grid in π or a2O(rlogr)-wide decomposition ofπ.

Theorem (essentially[Marcus and Tardos 2004]) IfM is a point set in [p]×[q]with |M|>r4 rr2

(p+q), then we can find anr×r-grid in M.

(27)

Finding decompositions

Large grids imply large width:

Fact

Ifπ contains anr×r-grid, then every decomposition of π is Ω(r)-wide.

Large width implies large grids:

Theorem

There is anO(n) time algorithm that finds either an r×r grid in π or a2O(rlogr)-wide decomposition ofπ.

The algorithm relies on the following previous result:

Theorem (essentially[Marcus and Tardos 2004])

(28)

We maintain a partition of rows and columns that is compatible with every current rectangle and satisfies that

every row/column contains<r0 rectangles and

every two adjacent rows/columns contain ≥r0 rectangles.

<r0

r0

p rows

q columns

(29)

Finding decompositions

We maintain a partition of rows and columns that is compatible with every current rectangle and satisfies that

every row/column contains<r0 rectangles and

every two adjacent rows/columns contain ≥r0 rectangles.

<r0

r0

p rows

q columns

Case 1: If a cell contains two rectangles, merge them. If two adja-

(30)

We maintain a partition of rows and columns that is compatible with every current rectangle and satisfies that

every row/column contains<r0 rectangles and

every two adjacent rows/columns contain ≥r0 rectangles.

<r0

<r0

!!! p rows

q columns

Case 1: If a cell contains two rectangles, merge them. If two adja- cent rows/columns contain<r0 rectangles, then merge them.

(31)

Finding decompositions

We maintain a partition of rows and columns that is compatible with every current rectangle and satisfies that

every row/column contains<r0 rectangles and

every two adjacent rows/columns contain ≥r0 rectangles.

<r0

r0 p rows

q columns

Case 1: If a cell contains two rectangles, merge them. If two adja-

(32)

We maintain a partition of rows and columns that is compatible with every current rectangle and satisfies that

every row/column contains<r0 rectangles and

every two adjacent rows/columns contain ≥r0 rectangles.

<r0

r0

p rows

q columns

Case 2: Every cell contains at most one rectangle

⇒There are Ω((p+q)r0) nonempty cells

(33)

Finding patterns

We would like to design a dynamic programming algorithm to solve Permutation Patternusing a given decomposition.

Problem:

The decomposition does not break the problem into independent subproblems.

R

1 2

(34)

Finding patterns

We would like to design a dynamic programming algorithm to solve Permutation Patternusing a given decomposition.

Problem:

The decomposition does not break the problem into independent subproblems.

R1

R2

(35)

Finding patterns

We would like to design a dynamic programming algorithm to solve Permutation Patternusing a given decomposition.

Problem:

The decomposition does not break the problem into independent subproblems.

R1

R2

(36)

We would like to design a dynamic programming algorithm to solve Permutation Patternusing a given decomposition.

Problem:

The decomposition does not break the problem into independent subproblems.

R1

R2

(37)

Connected components

Visibility graph: two rectangles are adjacent if they see each other horizontally or vertically.

Observation: The degree of the visibility graph is less than 2d if the rectangle family isd-wide. Therefore, there aredO(`)·n setsK of size≤`that are connected in the visibility graph.

(38)

Visibility graph: two rectangles are adjacent if they see each other horizontally or vertically.

Subproblems defined by

stepi of the decomposition,

a connected set K of size ≤`in the visibility graph, a subpermutationσ0 ifσ, and

(39)

Connected components

How to solve a subproblem at stepi using the subproblems at step i−1?

1

R2, then we have to distribute the points assigned toR in every possible way between R1 andR2.

In step i−1, set K falls apart into some number of connected sets, but the interaction between them is completely

understood.

(40)

How to solve a subproblem at stepi using the subproblems at step i−1?

R

If a rectangle R of K was created at step i by mergingR1 and R2, then we have to distribute the points assigned toR in every possible way between R1 andR2.

In step i−1, set K falls apart into some number of connected sets, but the interaction between them is completely

understood.

(41)

Connected components

How to solve a subproblem at stepi using the subproblems at step i−1?

R1 R2

If a rectangle R of K was created at step i by mergingR1 and R2, then we have to distribute the points assigned toR in every possible way between R1 andR2.

In step i−1, set K falls apart into some number of connected

(42)

Theorem

Permutation Patterncan be solved in time 2O(`2log`)·n, where`=|σ|andn =|π|.

Win/win strategy:

1 There is an algorithm that either findsσinπor

finds a2O(`log`)-wide decomposition ofπ.

2 There is an algorithm that, given σ and ad-wide

decomposition ofπ, decides ifσ is a subpattern ofπ in time (d`)O(`)·n.

(43)

Hardness

Partitioned Permutation Pattern: for every i ∈σ, a subsetSi ⊆π is given where it can be mapped.

Theorem

Partitioned Permutation Patternis W[1]-hard parameterized by|σ|.

3-Dimensional Permutation Pattern: natural generalization to 3-dimensional points in general position.

Theorem

3-Dimensional Permutation Patternis W[1]-hard parameterized by|σ|.

(44)

Finding patterns in permutations is fixed-parameter tractable.

Algorithm is based on a novel width measure for permutations.

Win/win situation similar to certain algorithms based on minors and bidimensionality.

But our decomposition is strictly speaking not a decomposition.

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

Our main result gives a criterion for a multigraph to be decomposed into two odd subgraphs, and proposes a polynomial time algorithm for finding such a decomposition or showing

In this paper, we would like to fill this gap in oscillation theory and to establish a new comparison principle for advanced equations..

For the latter purpose the optimal solution of the ILP algorithm was used as reference in those problem instances that both algorithms were able to solve in acceptable time.. We

The subproblems of the dynamic programming are as follows: at each step of the decomposition, for each set K of size at most ` that is connected in the visibility graph, we have

Furthermore, we prove that Exact Stable Bipartization (Is there an independent set of size exactly k whose removal makes the graph bipartite?) is also almost linear-time FPT,

Remember that we have learnt a polynomial time algorithm for finding maximum matching in a bipartite graph?. The formalization works for all kind of graphs so it looks like a

Therefore, the concept of maximally redundant trees was introduced [28]. A pair of maximally redundant trees rooted at a given root vertex of an undirected graph is a pair of

In the generative design, the 3D shape of the real structure is made using an algorithm with predefined editing rules.. With an algorithm, it is possible to carry out a