Fast and Longest Rollercoasters
Abstract
For , a k-rollercoaster is a sequence of numbers whose every maximal contiguous subsequence, that is increasing or decreasing, has length at least ; -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 -rollercoaster. Biedl et al. [ICALP 2018] have shown that each sequence of distinct real numbers contains a rollercoaster of length at least for , and that a longest rollercoaster contained in such a sequence can be computed in -time. They have also shown that every sequence of distinct real numbers contains a -rollercoaster of length at least , and gave an -time algorithm computing a longest -rollercoaster in a sequence of length . In this paper, we give an -time algorithm computing the length of a longest -rollercoaster contained in a sequence of distinct real numbers; hence, for constant , our algorithm computes the length of a longest -rollercoaster in optimal linear time. The algorithm can be easily adapted to output the respective -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 -rollercoaster in -time, that is, subquadratic even for large values of . Again, the rollercoaster can be easily retrieved. Finally, we show an lower bound for the number of comparisons in any comparison-based algorithm computing the length of a longest -rollercoaster.
Cite
@article{arxiv.1810.07422,
title = {Fast and Longest Rollercoasters},
author = {Paweł Gawrychowski and Florin Manea and Radosław Serafin},
journal= {arXiv preprint arXiv:1810.07422},
year = {2019}
}