A rollercoaster is a sequence of real numbers for which every maximal contiguous subsequence, that is increasing or decreasing, has length at least three. By translating this sequence to a set of points in the plane, a rollercoaster can be defined as a polygonal path for which every maximal sub-path, with positive- or negative-slope edges, has at least three points. Given a sequence of distinct real numbers, the rollercoaster problem asks for a maximum-length subsequence that is a rollercoaster. It was conjectured that every sequence of $n$ distinct real numbers contains a rollercoaster of length at least $\lceil n/2\rceil$ for $n>7$, while the best known lower bound is $\Omega(n/\log n)$. In this paper we prove this conjecture. Our proof is constructive and implies a linear-time algorithm for computing a rollercoaster of this length. Extending the $O(n\log n)$-time algorithm for computing a longest increasing subsequence, we show how to compute a maximum-length rollercoaster within the same time bound. A maximum-length rollercoaster in a permutation of $\{1,\dots,n\}$ can be computed in $O(n \log \log n)$ time.
The search for rollercoasters was motivated by orthogeodesic point-set embedding of caterpillars. A caterpillar is a tree such that deleting the leaves gives a path, called the spine. A top-view caterpillar is one of degree 4 such that the two leaves adjacent to each vertex lie on opposite sides of the spine. As an application of our result on rollercoasters, we are able to find a planar drawing of every $n$-node top-view caterpillar on every set of $\frac{25}{3}n$ points in the plane, such that each edge is an orthogonal path with one bend. This improves the previous best known upper bound on the number of required points, which is $O(n \log n)$. We also show that such a drawing can be obtained in linear time, provided that the points are given in sorted order.
[1]
J. Michael Steele,et al.
Variations on the Monotone Subsequence Theme of Erdös and Szekeres
,
1995
.
[2]
Maxime Crochemore,et al.
Fast computation of a longest increasing subsequence and application
,
2010,
Inf. Comput..
[3]
J. Hammersley.
A few seedlings of research
,
1972
.
[4]
M. Scheucher.
Orthogeodesic Point Set Embeddings of Outerplanar Graphs
,
2015
.
[5]
Timothy M. Chan,et al.
Improved Bounds for Drawing Trees on Fixed Points with L-Shaped Edges
,
2017,
Graph Drawing.
[6]
G. Szekeres,et al.
A combinatorial problem in geometry
,
2009
.
[7]
Emilio Di Giacomo,et al.
Orthogeodesic point-set embedding of trees
,
2013,
Comput. Geom..
[8]
Peter M. Fenwick,et al.
A new data structure for cumulative frequency tables
,
1994,
Softw. Pract. Exp..
[9]
Nicolas Basset,et al.
Counting and Generating Permutations in Regular Classes
,
2016,
Algorithmica.
[10]
Richard Ehrenborg,et al.
Descent pattern avoidance
,
2012,
Adv. Appl. Math..
[11]
D. Romik.
The Surprising Mathematics of Longest Increasing Subsequences
,
2015
.
[12]
Peter van Emde Boas,et al.
Preserving Order in a Forest in Less Than Logarithmic Time and Linear Space
,
1977,
Inf. Process. Lett..
[13]
Sergey Kitaev,et al.
Patterns in Permutations and Words
,
2011,
Monographs in Theoretical Computer Science. An EATCS Series.
[14]
Michael L. Fredman,et al.
On computing the length of longest increasing subsequences
,
1975,
Discret. Math..