Fast and Longest Rollercoasters
For k >= 3, a k-rollercoaster is a sequence of numbers whose every maximal contiguous subsequence, that is increasing or decreasing, has length at least k; 3-rollercoasters are called simply rollercoasters. Given a sequence of distinct real numbers, we are interested in computing its maximum-length (not necessarily contiguous) subsequence that is a k-rollercoaster. Biedl et al. (2018) have shown that each sequence of n distinct real numbers contains a rollercoaster of length at least ceil[n/2] for n>7, and that a longest rollercoaster contained in such a sequence can be computed in O(n log n)-time (or faster, in O(n log log n) time, when the input sequence is a permutation of {1,...,n}). They have also shown that every sequence of n >=slant (k-1)^2+1 distinct real numbers contains a k-rollercoaster of length at least n/(2(k-1)) - 3k/2, and gave an O(nk log n)-time (respectively, O(n k log log n)-time) algorithm computing a longest k-rollercoaster in a sequence of length n (respectively, a permutation of {1,...,n}).
In this paper, we give an O(nk^2)-time algorithm computing the length of a longest k-rollercoaster contained in a sequence of n distinct real numbers; hence, for constant k, our algorithm computes the length of a longest k-rollercoaster in optimal linear time. The algorithm can be easily adapted to output the respective k-rollercoaster. In particular, this improves the results of Biedl et al. (2018), by showing that a longest rollercoaster can be computed in optimal linear time. We also present an algorithm computing the length of a longest k-rollercoaster in O(n log^2 n)-time, that is, subquadratic even for large values of k <= n. Again, the rollercoaster can be easily retrieved. Finally, we show an Omega(n log k) lower bound for the number of comparisons in any comparison-based algorithm computing the length of a longest k-rollercoaster.
sequences
alternating runs
patterns in permutations
Theory of computation~Design and analysis of algorithms
Theory of computation~Data structures design and analysis
30:1-30:17
Regular Paper
Paweł
Gawrychowski
Paweł Gawrychowski
Institute of Computer Science, University of Wrocław, Poland
Florin
Manea
Florin Manea
Kiel University, Germany
Radosław
Serafin
Radosław Serafin
Institute of Computer Science, University of Wrocław, Poland
10.4230/LIPIcs.STACS.2019.30
Alok Aggarwal and Maria M. Klawe. Applications of generalized matrix searching to geometric algorithms. Discrete Applied Mathematics, 27(1-2):3-23, 1990.
Alok Aggarwal, Maria M. Klawe, Shlomo Moran, Peter W. Shor, and Robert E. Wilber. Geometric Applications of a Matrix-Searching Algorithm. Algorithmica, 2:195-208, 1987.
David Aldous and Persi Diaconis. Longest Increasing Subsequences: From Patience Sorting to the Baik-Deift-Johansson Theorem. Bulletin of the American Mathematical Society, 36:413-432, 1999.
Sergei Bespamyatnikh and Michael Segal. Enumerating longest increasing subsequences and patience sorting. Information Processing Letters, 76(1):7-11, 2000.
Therese C. Biedl, Ahmad Biniaz, Robert Cummings, Anna Lubiw, Florin Manea, Dirk Nowotka, and Jeffrey Shallit. Rollercoasters and Caterpillars. In ICALP, volume 107 of LIPIcs, pages 18:1-18:15. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2018.
Therese C. Biedl, Timothy M. Chan, Martin Derka, Kshitij Jain, and Anna Lubiw. Improved Bounds for Drawing Trees on Fixed Points with L-Shaped Edges. In Graph Drawing and Network Visualization - 25th International Symposium, GD 2017, Revised Selected Papers, volume 10692 of Lecture Notes in Computer Science, pages 305-317. Springer, 2017.
Bernard Chazelle. A Functional Approach to Data Structures and Its Use in Multidimensional Searching. SIAM J. Comput., 17(3):427-462, 1988.
Maxime Crochemore and Ely Porat. Fast Computation of a Longest Increasing Subsequence and Application. Information and Computation, 208(9):1054-1059, 2010.
Paul Erdős and George Szekeres. A combinatorial problem in geometry. Compositio Mathematica, 2:463-470, 1935.
Michael L. Fredman. On computing the length of longest increasing subsequences. Discrete Mathematics, 11(1):29-35, 1975.
Hania Gajewska and Robert Endre Tarjan. Deques with Heap Order. Information Processing Letters, 22(4):197-200, 1986.
P. Gawrychowski, F. Manea, and R. Serafin. Fast and Longest Rollercoasters. arXiv, 2018. URL: http://arxiv.org/abs/1810.07422.
http://arxiv.org/abs/1810.07422
James W. Hunt and Thomas G. Szymanski. A Fast Algorithm for Computing Longest Common Subsequences. Communications of the ACM, 20(5):350-353, 1977.
Sergey Kitaev. Patterns in Permutations and Words. Springer, 2011.
S. Linton, N. Ruškuc, and V. Vatter, editors. Permutation Patterns. London Mathematical Society Lecture Note Series, vol. 376, Cambridge, 2010.
Dan Romik. The Surprising Mathematics of Longest Increasing Subsequences. Cambridge, 2015.
Craige Schensted. Longest increasing and decreasing subsequences. Canadian Journal of Mathematics, 13:179-191, 1961.
J. Michael Steele. Variations on the monotone subsequence theme of Erdős and Szekeres. In David Aldous, Persi Diaconis, Joel Spencer, and J. Michael Steele, editors, Discrete Probability and Algorithms, pages 111-131. Springer New York, 1995.
Xiaoming Sun and David P. Woodruff. The Communication and Streaming Complexity of Computing the Longest Common and Increasing Subsequences. In Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '07, pages 336-345. Society for Industrial and Applied Mathematics, 2007.
Alexander Tiskin. Fast Distance Multiplication of Unit-Monge Matrices. Algorithmica, 71(4):859-888, 2015.
Paweł Gawrychowski, Florin Manea, and Radosław Serafin
Creative Commons Attribution 3.0 Unported license
https://creativecommons.org/licenses/by/3.0/legalcode