Fast and Longest Rollercoasters

10/17/2018
by   Paweł Gawrychowski, et al.
0

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 numbers, we are interested in computing its maximum-length (not necessarily contiguous) subsequence that is a k-rollercoaster. Biedl et al. [ICALP 2018] have shown that each sequence of n distinct real numbers contains a rollercoaster of length at least n/2 for n>7, and that a longest rollercoaster contained in such a sequence can be computed in O(n n)-time. They have also shown that every sequence of n≥ (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 n)-time algorithm computing a longest k-rollercoaster in a sequence of length 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. [ICALP 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 ^2 n)-time, that is, subquadratic even for large values of k≤ n. Again, the rollercoaster can be easily retrieved. Finally, we show an Ω(n k) lower bound for the number of comparisons in any comparison-based algorithm computing the length of a longest k-rollercoaster.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
01/25/2018

Rollercoasters and Caterpillars

A rollercoaster is a sequence of real numbers for which every maximal co...
research
07/06/2022

Improving Order with Queues

Patience Sort sorts a sequence of numbers with a minimal number of queue...
research
06/20/2023

Max-convolution through numerics and tropical geometry

The maximum function, on vectors of real numbers, is not differentiable....
research
08/08/2023

Linear Time Construction of Cover Suffix Tree and Applications

The Cover Suffix Tree (CST) of a string T is the suffix tree of T with a...
research
09/20/2019

Formations and generalized Davenport-Schinzel sequences

An (r, s)-formation is a concatenation of s permutations of r distinct l...
research
02/18/2018

Linear-Time Algorithm for Long LCF with k Mismatches

In the Longest Common Factor with k Mismatches (LCF_k) problem, we are g...
research
03/13/2023

Optimal Square Detection Over General Alphabets

Squares (fragments of the form xx, for some string x) are arguably the m...

Please sign up or login with your details

Forgot password? Click here to reset