English

Fast Algorithms for Finding Pattern Avoiders and Counting Pattern Occurrences in Permutations

Discrete Mathematics 2017-03-20 v4 Data Structures and Algorithms Combinatorics

Abstract

Given a set Π\Pi of permutation patterns of length at most kk, we present an algorithm for building Sn(Π)S_{\le n}(\Pi), the set of permutations of length at most nn avoiding the patterns in Π\Pi, in time O(Sn1(Π)k+Sn(Π))O(|S_{\le n - 1}(\Pi)| \cdot k + |S_{n}(\Pi)|). Additionally, we present an O(n!k)O(n!k)-time algorithm for counting the number of copies of patterns from Π\Pi in each permutation in SnS_n. Surprisingly, when Π=1|\Pi| = 1, this runtime can be improved to O(n!)O(n!), spending only constant time per permutation. Whereas the previous best algorithms, based on generate-and-check, take exponential time per permutation analyzed, all of our algorithms take time at most polynomial per outputted permutation. If we want to solve only the enumerative variant of each problem, computing Sn(Π)|S_{\le n}(\Pi)| or tallying permutations according to Π\Pi-patterns, rather than to store information about every permutation, then all of our algorithms can be implemented in O(nk+1k)O(n^{k+1}k) space. Using our algorithms, we generated S5(Π),,S16(Π)|S_5(\Pi)|, \ldots, |S_{16}(\Pi)| for each ΠS4\Pi \subseteq S_4 with Π>4|\Pi| > 4, and analyzed OEIS matches. We obtained a number of potentially novel pattern-avoidance conjectures. Our algorithms extend to considering permutations in any set closed under standardization of subsequences. Our algorithms also partially adapt to considering vincular patterns.

Keywords

Cite

@article{arxiv.1509.08216,
  title  = {Fast Algorithms for Finding Pattern Avoiders and Counting Pattern Occurrences in Permutations},
  author = {William Kuszmaul},
  journal= {arXiv preprint arXiv:1509.08216},
  year   = {2017}
}
R2 v1 2026-06-22T11:06:44.905Z