Abstract

For kge 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. (in: ICALP, volume 107 of LIPIcs. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, pp 18:1–18:15, 2018) have shown that each sequence of n distinct real numbers contains a rollercoaster of length at least lceil n/2rceil for n>7, and that a longest rollercoaster contained in such a sequence can be computed in O(nlog n)-time (or faster, in O(n log log n) time, when the input sequence is a permutation of {1,ldots ,n}). They have also shown that every sequence of ngeqslant (k-1)^2+1 distinct real numbers contains a k-rollercoaster of length at least frac{n}{2(k-1)}-frac{3k}{2}, and gave an O(nklog n)-time (respectively, O(n klog log n)-time) algorithm computing a longest k-rollercoaster in a sequence of length n (respectively, a permutation of {1,ldots ,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 kle 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.

Highlights

  • The mathematical study of patterns occurring in sequences of numbers is a rather old and well developed topic in combinatorics and algorithms on sequences

  • We design a comparison-based algorithm computing the length of a longest k-rollercoaster in a sequence of n distinct numbers in O(nk2) time

  • We leave as an open problem to close the gap between the lower and upper bounds shown here

Read more

Summary

Introduction

The mathematical study of patterns occurring in sequences of numbers is a rather old and well developed topic in combinatorics and algorithms on sequences. We design a comparison-based algorithm computing the length of a longest k-rollercoaster in a sequence of n distinct numbers in O(nk2) time. We obtain an optimal linear-time algorithm for constant values of k, in particular for k = 3 This significantly improves the results of [5,6] and shows that, even though longest rollercoasters are related to longest increasing subsequences, the rich combinatorial structure of the former makes them provably easier to find. We design a subquadratic algorithm that computes a longest k-rollercoaster in a sequence of n distinct numbers, for any k, in O(n log n) time To obtain this result, we exploit the fact that if an increasing (respectively, decreasing) run in a longest k-rollercoaster extends from S[i] to S[ j], that run should be LIS (respectively, longest decreasing sequence, LDS for short) in S[i : j]. We conclude with the lower bound for the number of comparisons needed to compute the length of a longest k-rollercoaster in a sequence of length n

Preliminaries
Preprocessing Phase
Combinatorial Lemmas
The Main Phase
Conclusion and Overall Complexity
Constructing a Longest k-Rollercoaster
Lower Bound
Conclusions
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call