{"@context":"https:\/\/schema.org\/","@type":"ScholarlyArticle","@id":"#article12058","name":"Fast and Longest Rollercoasters","abstract":"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}).\r\nIn 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.","keywords":["sequences","alternating runs","patterns in permutations"],"author":[{"@type":"Person","name":"Gawrychowski, Pawe\u0142","givenName":"Pawe\u0142","familyName":"Gawrychowski","email":"mailto:gawry@cs.uni.wroc.pl","affiliation":"Institute of Computer Science, University of Wroc\u0142aw, Poland"},{"@type":"Person","name":"Manea, Florin","givenName":"Florin","familyName":"Manea","email":"mailto:flm@informatik.uni-kiel.de","affiliation":"Kiel University, Germany"},{"@type":"Person","name":"Serafin, Rados\u0142aw","givenName":"Rados\u0142aw","familyName":"Serafin","email":"mailto:radserafin@gmail.com","affiliation":"Institute of Computer Science, University of Wroc\u0142aw, Poland"}],"position":30,"pageStart":"30:1","pageEnd":"30:17","dateCreated":"2019-03-12","datePublished":"2019-03-12","isAccessibleForFree":true,"license":"https:\/\/creativecommons.org\/licenses\/by\/3.0\/legalcode","copyrightHolder":[{"@type":"Person","name":"Gawrychowski, Pawe\u0142","givenName":"Pawe\u0142","familyName":"Gawrychowski","email":"mailto:gawry@cs.uni.wroc.pl","affiliation":"Institute of Computer Science, University of Wroc\u0142aw, Poland"},{"@type":"Person","name":"Manea, Florin","givenName":"Florin","familyName":"Manea","email":"mailto:flm@informatik.uni-kiel.de","affiliation":"Kiel University, Germany"},{"@type":"Person","name":"Serafin, Rados\u0142aw","givenName":"Rados\u0142aw","familyName":"Serafin","email":"mailto:radserafin@gmail.com","affiliation":"Institute of Computer Science, University of Wroc\u0142aw, Poland"}],"copyrightYear":"2019","accessMode":"textual","accessModeSufficient":"textual","creativeWorkStatus":"Published","inLanguage":"en-US","sameAs":"https:\/\/doi.org\/10.4230\/LIPIcs.STACS.2019.30","publisher":"Schloss Dagstuhl \u2013 Leibniz-Zentrum f\u00fcr Informatik","citation":"http:\/\/arxiv.org\/abs\/1810.07422","isPartOf":{"@type":"PublicationVolume","@id":"#volume6329","volumeNumber":126,"name":"36th International Symposium on Theoretical Aspects of Computer Science (STACS 2019)","dateCreated":"2019-03-12","datePublished":"2019-03-12","editor":[{"@type":"Person","name":"Niedermeier, Rolf","givenName":"Rolf","familyName":"Niedermeier","email":"mailto:rolf.niedermeier@tu-berlin.de","affiliation":"Algorithmics and Computational Complexity, Fakult\u00e4t IV, TU Berlin, Berlin, Germany"},{"@type":"Person","name":"Paul, Christophe","givenName":"Christophe","familyName":"Paul","email":"mailto:christophe.paul@lirmm.fr","affiliation":"CNRS, Universit\u00e9 de Montpellier, LIRMM, Montpellier, France"}],"isAccessibleForFree":true,"publisher":"Schloss Dagstuhl \u2013 Leibniz-Zentrum f\u00fcr Informatik","hasPart":"#article12058","isPartOf":{"@type":"Periodical","@id":"#series116","name":"Leibniz International Proceedings in Informatics","issn":"1868-8969","isAccessibleForFree":true,"publisher":"Schloss Dagstuhl \u2013 Leibniz-Zentrum f\u00fcr Informatik","hasPart":"#volume6329"}}}