Remote Access Mathematics of Computation
Green Open Access

Mathematics of Computation

ISSN 1088-6842(online) ISSN 0025-5718(print)

Request Permissions   Purchase Content 


Fast algorithms for finding pattern avoiders and counting pattern occurrences in permutations

Author: William Kuszmaul
Journal: Math. Comp. 87 (2018), 987-1011
MSC (2010): Primary 05A05; Secondary 68W01
Published electronically: May 31, 2017
Full-text PDF

Abstract | References | Similar Articles | Additional Information

Abstract: Given a set $ \Pi $ of permutation patterns of length at most $ k$, we present an algorithm for building $ S_{\le n}(\Pi )$, the set of permutations of length at most $ n$ avoiding the patterns in $ \Pi $, in time $ O(\vert S_{\le n - 1}(\Pi )\vert \cdot k + \vert S_{n}(\Pi )\vert)$. Additionally, we present an $ O(n!k)$-time algorithm for counting the number of copies of patterns from $ \Pi $ in each permutation in $ S_n$. Surprisingly, when $ \vert\Pi \vert = 1$, this runtime can be improved to $ 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 $ \vert S_{\le n}(\Pi )\vert$ 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(n^{k+1}k)$ space.

Our algorithms extend to considering permutations in any set closed under standardization of subsequences. Our algorithms also partially adapt to considering vincular patterns.

References [Enhancements On Off] (What's this?)

  • [1] Shlomo Ahal and Yuri Rabinovich, On complexity of the subpattern problem, SIAM J. Discrete Math. 22 (2008), no. 2, 629-649. MR 2399369,
  • [2] Michael Albert, Permlab: Software for permutation patterns, 2012,, 2012.
  • [3] Michael H. Albert, Robert E. L. Aldred, Mike D. Atkinson, and Derek A. Holton, Algorithms for pattern involvement in permutations, Algorithms and Computation (Christchurch, 2001) Lecture Notes in Comput. Sci., vol. 2223, Springer, Berlin, 2001, pp. 355-366. MR 1917756,
  • [4] Eric Babson and Einar Steingrímsson, Generalized permutation patterns and a classification of the Mahonian statistics, Sém. Lothar. Combin. 44 (2000), Art. B44b, 18 pp. (electronic). MR 1758852
  • [5] Jörgen Backelin, Julian West, and Guoce Xin, Wilf-equivalence for singleton classes, Adv. in Appl. Math. 38 (2007), no. 2, 133-148. MR 2290807,
  • [6] Prosenjit Bose, Jonathan F. Buss, and Anna Lubiw, Pattern matching for permutations, Inform. Process. Lett. 65 (1998), no. 5, 277-283. MR 1620935,
  • [7] Marie-Louise Bruner and Martin Lackner, The computational landscape of permutation patterns, Pure Math. Appl. (PU.M.A.) 24 (2013), no. 2, 83-101. MR 3266905
  • [8] Marie-Louise Bruner and Martin Lackner, A fast algorithm for permutation pattern matching based on alternating runs, Algorithmica 75 (2016), no. 1, 84-117. MR 3492057,
  • [9] Anders Claesson, Generalized pattern avoidance, European J. Combin. 22 (2001), no. 7, 961-971. MR 1857258,
  • [10] Anders Claesson, Vít Jelínek, and Einar Steingrímsson, Upper bounds for the Stanley-Wilf limit of 1324 and other layered patterns, J. Combin. Theory Ser. A 119 (2012), no. 8, 1680-1691. MR 2946382,
  • [11] P. Erdös and G. Szekeres, A combinatorial problem in geometry, Compositio Math. 2 (1935), 463-470. MR 1556929
  • [12] Sylvain Guillemot and Dániel Marx, Finding small patterns in permutations in linear time, Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, ACM, New York, 2014, pp. 82-101. MR 3376367,
  • [13] Y. Han, S. Saxena, and X. Shen, An efficient parallel algorithm for building the separating tree, Journal of Parallel and Distributed Computing 70 (2010), no. 6, 625-629.
  • [14] Y. Han and S. Saxena, Parallel algorithms for testing length four permutations, Parallel Architectures, Algorithms and Programming (PAAP), 2014 Sixth International Symposium on, IEEE, 2014, pp. 81-86.
  • [15] Louis Ibarra, Finding pattern matchings for permutations, Inform. Process. Lett. 61 (1997), no. 6, 293-295. MR 1448525,
  • [16] Y. Inoue, T. Takahisa, and S.-I. Minato, Generating sets of permutations with pattern occurrence counts using permutation decision diagrams, TCS Technical Report, Series A 14 (2014), no. 78.
  • [17] Y. Inoue, T. Takahisa, and S.-I. Minato, Implicit generation of pattern-avoiding permutations by using permutation decision diagrams, IEICE Transactions on Fundamentals of Electronics, Communications and Computer Sciences 97 (2014), no. 6, 1171-1179.
  • [18] Jinil Kim, Peter Eades, Rudolf Fleischer, Seok-Hee Hong, Costas S. Iliopoulos, Kunsoo Park, Simon J. Puglisi, and Takeshi Tokuyama, Order-preserving matching, Theoret. Comput. Sci. 525 (2014), 68-79. MR 3174114,
  • [19] Sergey Kitaev, Patterns in permutations and words, Monographs in Theoretical Computer Science. An EATCS Series, Springer, Heidelberg, 2011. With a foreword by Jeffrey B. Remmel. MR 3012380
  • [20] Donald E. Knuth, The Art of Computer Programming. Vol. 3: Sorting and Searching, Addison-Wesley, Reading, MA, 1998. Second edition [of MR0445948]. MR 3077154
  • [21] M. Kubica, T. Kulczyński, J. Radoszewski, W. Rytter, and T. Waleń, A linear time algorithm for consecutive permutation pattern matching, Inform. Process. Lett. 113 (2013), no. 12, 430-433. MR 3042127,
  • [22] W. Kuszmaul, Fast algorithms for finding pattern avoiders and counting pattern occurrences in permutations, arXiv preprint arXiv:1509.08216 (2015).
  • [23] Adam Marcus and Gábor Tardos, Excluded permutation matrices and the Stanley-Wilf conjecture, J. Combin. Theory Ser. A 107 (2004), no. 1, 153-160. MR 2063960,
  • [24] Michal Opler, Major index distribution over permutation classes, Adv. in Appl. Math. 80 (2016), 131-150. MR 3537243,
  • [25] Rodica Simion and Frank W. Schmidt, Restricted permutations, European J. Combin. 6 (1985), no. 4, 383-406. MR 829358,
  • [26] N. J. A. Sloane, The on-line encyclopedia of integer sequences, Notices Amer. Math. Soc. 50 (2003), no. 8, 912-915. MR 1992789
  • [27] W. A. Stein, T. Abbott, M. Abshoff, et al., Sage mathematics software, 2011.
  • [28] V. Yugandhar and Sanjeev Saxena, Parallel algorithms for separable permutations, Discrete Appl. Math. 146 (2005), no. 3, 343-364. MR 2115153,

Similar Articles

Retrieve articles in Mathematics of Computation with MSC (2010): 05A05, 68W01

Retrieve articles in all journals with MSC (2010): 05A05, 68W01

Additional Information

William Kuszmaul
Affiliation: Department of Computer Science, Stanford University, Stanford, California 94305

Received by editor(s): October 6, 2015
Received by editor(s) in revised form: July 3, 2016, and September 19, 2016
Published electronically: May 31, 2017
Additional Notes: This research was conducted at the University of Minnesota Duluth REU and was supported by NSF grant 1358659 and NSA grant H98230-13-1-0273. Machine time was provided by an AWS in Education Research grant.
Article copyright: © Copyright 2017 American Mathematical Society

American Mathematical Society