Skip to main content
Log in

A Fast Algorithm for Permutation Pattern Matching Based on Alternating Runs

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

The NP-complete Permutation Pattern Matching problem asks whether a k-permutation P is contained in a n-permutation T as a pattern. This is the case if there exists an order-preserving embedding of P into T. In this paper, we present a fixed-parameter algorithm solving this problem with a worst-case runtime of \({\mathcal O}(1.79^{\mathsf {run}(T)}\cdot n\cdot k)\), where \(\mathsf {run}(T)\) denotes the number of alternating runs of T. This algorithm is particularly well-suited for instances where T has few runs, i.e., few ups and downs. Moreover, since \(\mathsf {run}(T)<n\), this can be seen as a \({\mathcal O}(1.79^{n}\cdot n\cdot k)\) algorithm which is the first to beat the exponential \(2^n\) runtime of brute-force search. Furthermore, we prove that under standard complexity theoretic assumptions such a fixed-parameter tractability result is not possible for \(\mathsf {run}(P)\).

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7

Similar content being viewed by others

Notes

  1. The reason why we do not set \(b_{\mathsf {run}(P)}=\lfloor \mathsf {run}(F(\mathsf {run}(P))/2\rfloor \) is a rather technical one: \(F(\mathsf {run}(P))\) may end with a run up if the last run in P is a run up and may end with a run down if the last run in P is a run down. This would lead to unwanted collisions concerning the Index function and consequently would prohibit the proof of Lemma 5.

References

  1. Ahal, S., Rabinovich, Y.: On complexity of the subpattern problem. SIAM J. Discrete Math. 22(2), 629–649 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  2. Albert, M., Aldred, R., Atkinson, M., Holton, D.: Algorithms for pattern involvement in permutations. In: Eades, P., Takaoka, T. (eds.) Algorithms and Computation, Lecture Notes in Computer Science, vol. 2223, pp. 355–367. Springer, Berlin (2001)

    Google Scholar 

  3. Albert, M.H., Aldred, R.E.L., Atkinson, M.D., van Ditmarsch, H.P., Handley, B.D., Handley, C.C., Opatrny, J.: Longest subsequences in permutations. Australas. J. Comb. 28, 225–238 (2003)

    MathSciNet  MATH  Google Scholar 

  4. André, D.: Étude sur les maxima, minima et séquences des permutations. Annales scientifiques de l’École normale supérieure 3(1), 121–135 (1884)

    Google Scholar 

  5. Bóna, M.: Combinatorics of Permutations. Discrete Mathematics and Its Applications. Chapman & Hall/CRC, Boca Raton (2004)

    Book  Google Scholar 

  6. Bose, P., Buss, J.F., Lubiw, A.: Pattern matching for permutations. Inf. Process. Lett. 65(5), 277–283 (1998)

    Article  MathSciNet  Google Scholar 

  7. Bouvel, M., Rossin, D.: The longest common pattern problem for two permutations. Pure Math. Appl. 17(1–2), 55–69 (2006)

    MathSciNet  MATH  Google Scholar 

  8. Bouvel, M., Rossin, D., Vialette, S.: Longest common separable pattern among permutations. In: Ma, B., Zhang, K. (eds.) Combinatorial Pattern Matching, Lecture Notes in Computer Science, pp. 316–327. Springer, Berlin (2007)

    Chapter  Google Scholar 

  9. Bruner, M.L., Lackner, M.: A fast algorithm for permutation pattern matching based on alternating runs. In: Fomin, F.V., Kaski, P. (eds.) Algorithm Theory—SWAT 2012, Lecture Notes in Computer Science, vol. 7357, pp. 261–270. Springer, Berlin (2012)

    Google Scholar 

  10. Bruner, M.L., Lackner, M.: The computational landscape of permutation patterns. Pure Math. Appl. 24(2), 83–101 (2013)

    MathSciNet  MATH  Google Scholar 

  11. Chang, M.S., Wang, F.H.: Efficient algorithms for the maximum weight clique and maximum weight independent set problems on permutation graphs. Inf. Process. Lett. 43(6), 293–295 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  12. Crochemore, M., Iliopoulos, C.S., Kociumaka, T., Kubica, M., Langiu, A., Pissis, S.P., Radoszewski, J., Rytter, W., Waleń, T.: Order-preserving incomplete suffix trees and order-preserving indexes. In: Kurland, O., Lewenstein, M., Porat, E. (eds.) String Processing and Information Retrieval, Lecture Notes in Computer Science, vol. 8214, pp. 84–95. Springer, Berlin (2013)

    Chapter  Google Scholar 

  13. David, F.N., Barton, D.E.: Combinatorial Chance. Griffin, London (1962)

    Google Scholar 

  14. Downey, R., Fellows, M.: Fundamentals of Parameterized Complexity. Texts in Computer Science. Springer, Berlin (2013)

    Book  MATH  Google Scholar 

  15. Downey, R.G., Fellows, M.R.: Parameterized Complexity. Springer, Berlin (1999)

    Book  MATH  Google Scholar 

  16. Flajolet, P., Sedgewick, R.: Analytic Combinatorics. Cambridge University Press, Cambridge (2009)

    Book  MATH  Google Scholar 

  17. Flum, J., Grohe, M.: Parameterized Complexity Theory. Springer, Berlin (2006)

    MATH  Google Scholar 

  18. Fomin, F., Kratsch, D.: Exact Exponential Algorithms. Texts in Theoretical Computer Science. An EATCS Series. Springer, Berlin (2010)

    Google Scholar 

  19. Gawrychowski, P., Uznański, P.: Order-preserving pattern matching with \(k\) mismatches. In: Kulikov, A.S., Kuznetsov, S.O., Pevzner, P. (eds.) Combinatorial Pattern Matching, Lecture Notes in Computer Science, vol. 8486, pp. 130–139. Springer, Berlin (2014)

    Google Scholar 

  20. Guillemot, S., Marx, D.: Finding small patterns in permutations in linear time. In: Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA’14, pp. 82–101. SIAM (2014)

  21. Guillemot, S., Vialette, S.: Pattern matching for 321-avoiding permutations. In: Dong, Y., Du, D.Z., Ibarra, O. (eds.) Algorithms and Computation, Lecture Notes in Computer Science, vol. 5878, pp. 1064–1073. Springer, Berlin (2009)

    Google Scholar 

  22. Guo, J., Niedermeier, R.: Invitation to data reduction and problem kernelization. SIGACT News 38(1), 31–45 (2007)

    Article  Google Scholar 

  23. Ibarra, L.: Finding pattern matchings for permutations. Inf. Process. Lett. 61(6), 293–295 (1997)

    Article  MathSciNet  Google Scholar 

  24. Kim, J., Eades, P., Fleischer, R., Hong, S.H., Iliopoulos, C.S., Park, K., Puglisi, S.J., Tokuyama, T.: Order-preserving matching. Theor. Comput. Sci. 525, 68–79 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  25. Kitaev, S.: Patterns in Permutations and Words. Springer, Berlin (2011)

    Book  MATH  Google Scholar 

  26. Klenke, A.: Probability Theory: A Comprehensive Course. Springer, Berlin (2008)

    Book  MATH  Google Scholar 

  27. Knuth, D.E.: The Art of Computer Programming: Fundamental Algorithms, vol. I. Addison-Wesley, Reading (1968)

    MATH  Google Scholar 

  28. Kubica, M., Kulczyński, T., Radoszewski, J., Rytter, W., Wale, T.: A linear time algorithm for consecutive permutation pattern matching. Inf. Process. Lett. 113(12), 430–433 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  29. Levene, H., Wolfowitz, J.: The covariance matrix of runs up and down. Ann. Math. Stat. 15(1), 58–69 (1944)

    Article  MathSciNet  MATH  Google Scholar 

  30. Mäkinen, E.: On the longest upsequence problem for permutations. Int. J. Comput. Math. 77(1), 45–53 (2001)

    Article  MathSciNet  MATH  Google Scholar 

  31. Niedermeier, R.: Invitation to Fixed-Parameter Algorithms, Lecture Series in Mathematics and Its Applications. Oxford University Press, Oxford (2006)

    Book  Google Scholar 

  32. Saxena, S., Yugandhar, V.: Parallel algorithms for separable permutations. Discrete Appl. Math. 146(3), 343–364 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  33. Schensted, C.: Longest increasing and decreasing subsequences. Canad. J. Math. 13,179–191(1961)

  34. Simion, R., Schmidt, F.W.: Restricted permutations. Eur. J. Comb. 6, 383–406 (1985)

    Article  MathSciNet  MATH  Google Scholar 

  35. Van Emde Boas, P.: Machine models and simulations. In: Van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, vol. A. Elsevier, Amsterdam (1990)

    Google Scholar 

  36. Vatter, V.: Permutation patterns. In: Bóna, M. (ed.) Handbook of Enumerative Combinatorics. CRC Press, Boca Raton (2015)

    Google Scholar 

Download references

Acknowledgments

We would like to thank the anonymous reviewers for their feedback and suggestions leading to numerous improvements of this paper. The first author was supported by the Austrian Science Foundation FWF, Grant P25337-N23, the second author by the Austrian Science Foundation FWF, Grant P25518-N23 and Y698.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Marie-Louise Bruner.

Additional information

A preliminary version of this paper [9] appeared in the proceedings of the 13th Scandinavian Symposium and Workshops on Algorithm Theory, SWAT 2012.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Bruner, ML., Lackner, M. A Fast Algorithm for Permutation Pattern Matching Based on Alternating Runs. Algorithmica 75, 84–117 (2016). https://doi.org/10.1007/s00453-015-0013-y

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-015-0013-y

Keywords

Navigation