 Previous Article in Journal
Stability Analysis of Jacobian-Free Newton’s Iterative Method
Previous Article in Special Issue
Cyclotomic Trace Codes
Open AccessArticle

# What Do a Longest Increasing Subsequence and a Longest Decreasing Subsequence Know about Each Other?

by
Department of Computer Science, Ariel University, Ariel 40700, Israel
*
Authors to whom correspondence should be addressed.
Algorithms 2019, 12(11), 237; https://doi.org/10.3390/a12110237
Received: 21 August 2019 / Revised: 23 October 2019 / Accepted: 29 October 2019 / Published: 7 November 2019

## Abstract

As a kind of converse of the celebrated Erdős–Szekeres theorem, we present a necessary and sufficient condition for a sequence of length n to contain a longest increasing subsequence and a longest decreasing subsequence of given lengths x and y, respectively.

## 1. Introduction

In 1935, Hungarian mathematicians Paul Erdős and George Szekeres proved a celebrated theorem, which is now a classic, on relations between lengths of a sequence and its increasing (decreasing) subsequence .
Theorem 1.
(Erdős–Szekeres) Suppose
$a , b ∈ N , n ≥ a · b + 1$
and $x 1 , x 2 , … , x n$ is a sequence of real numbers. Then this sequence contains a monotonic increasing (decreasing) subsequence of $a + 1$ terms or a monotonic decreasing (increasing) subsequence of $b + 1$ terms.
More than 85 years have passed since then, and a whole subarea of combinatorics has grown up from the Erdős–Szekeres theorem. Even today we cannot fully appreciate the significance of this theorem, see, for instance, [2,3,4,5,6,7,8].
The main goal of this paper is to describe the complete family of constraints on the lengths of a sequence, its longest increasing subsequence, and its longest decreasing subsequence.

## 2. Results

Theorem 2.
There exists a sequence T of length $n ≥ 1$ containing a longest increasing subsequence of length $x = l i s ( T ) ≥ 1$ and a longest decreasing subsequence of length $y = l d s ( T ) ≥ 1$ if and only if the numbers x, y and n satisfy the following conditions:
$x · y ≥ n$
$x + y ≤ n + 1 .$
Proof.
If either $x = 1$ or $y = 1$ the claim is evident.
In what follows, $x > 1 , y > 1$, and $n > 1$.
Necessity of the condition (1) immediately follows from the theorem of Erdős–Szekeres. Assume that the condition (1) is not satisfied, i.e., $x · y ≤ n − 1$, then, according to the Erdős–Szekeres theorem, the sequence T of length n contains a monotone increasing subsequence of the length $x + 1$ or a monotone decreasing subsequence of the length $y + 1$, which contradicts the hypothesis of the theorem. The violation of the condition (2) makes impossible the existence of two subsequences with specified lengths, one of which increases, while the other decreases. In fact, these two subsequences can have no more than one element in common; that is, the sum of their lengths should not exceed $n + 1$.
Sufficiency. Assume that $x · y ≥ n$ and $x + y ≤ n + 1$, and build a sequence T of length n, such that $x = l i s ( T ) , y = l d s ( T )$. This sequence is built according to the following scheme. We take a sequence of n natural numbers $1 , 2 , … , n$ and divide it into x groups, in such a way that $T = C o n c a t e n a t i o n ( T 1 , T 2 , … , T x )$ and satisfies the following conditions:
• The numbers in each group are arranged in decreasing order.
• All the numbers of a subsequent group are greater than all the numbers of a preceding group.
• The first group consists of y elements: $y , y − 1 , y − 2 , … , 1$, which is possible by the condition $y < n$.
• We divide the remaining $n − y$ elements into $x − 1$ groups as follows. Let $p = n − y x − 1$ and $r = ( n − y ) mod ( x − 1 )$. Note that $p = n − y x − 1 ≥ x − 1 x − 1 = 1$ and $0 ≤ r < x − 1$. The first r groups represent decreasing subsequences $T 2 , … , T r + 1$ of the length $p + 1$:
$T 2 = { y + p + 1 , y + p , y + p − 1 , … , y + 1 }$
$T r + 1 = { y + r ( p + 1 ) , y + r ( p + 1 ) − 1 , … , y + r ( p + 1 ) − p }$.
The last $x − r − 1$ groups represent decreasing subsequences $T r + 2 , … , T x$ of length p. (If $r = 0$, then all $x − 1$ decreasing subsequences have the length p):
$T r + 2 = { y + r ( p + 1 ) + p , y + r ( p + 1 ) + p − 1 , … , y + r ( p + 1 ) + 1 }$,
$T x = { n , n − 1 , n − 2 , … , n − p + 1 } .$
Before passing to the proof of the sufficiency, we prove the following.
Claim 1.
At the partition of $n − y$ elements into $x − 1$ groups satisfying Conditions 1–4, the number of elements in each group does not exceed y.
Proof.
It is given that $y + p · ( x − 1 ) + r = n$. Then,
$y + p · ( x − 1 ) + r ≤ y + ( x − 1 ) · y$
in accordance with the condition $x · y ≥ n$. Thus
$p + r x − 1 ≤ y .$
If $r = 0$, then all $x − 1$ groups are of the same length p and $p ≤ y$.
If $r > 0$, then taking into account that $r < x − 1$, and the fact that p and y are positive integers, we conclude with $p + 1 ≤ y$, while all the groups are of length p or $p + 1$. □
By the above construction and Claim 1, the longest decreasing subsequence in T is the first group and thus has length y, while each longest increasing subsequence is obtained by choosing exactly one element from each of x groups, giving length x. □
Example 1.
Consider $n = 7 , x = 4 , y = 3$, and note that the conditions (1) and (2) are satisfied and $p = n − y x − 1 = 3$ and $r = 1$. By the construction given in the proof,
$T = ( 3 , 2 , 1 , 5 , 4 , 6 , 7 ) .$
Clearly, the longest decreasing sequence of T is $( 3 , 2 , 1 )$ and has length $y = 3$, and the longest increasing subsequences each have length $x = 4$.
Remark 1.
There are other methods of building sequences satisfying the conditions (1) and (2). For instance, by choosing the last group to be the longest decreasing subsequence rather than the first, or, say, by first creating the group consisting of x increasing integers $n − x + 1 , n − x + 2 , … , n$, and then adding $y − 1$ increasing groups of nearly equal size so that all the numbers in each group is smaller than the numbers in any previous group.

## Author Contributions

Conceptualization, E.J.I.; Investigation, V.E.L.; Writing–original draft preparation, V.E.L.; Writing–review and editing, E.J.I.

## Funding

This research received no external funding.

## Acknowledgments

We would like to thank the reviewers for their comments, which helped us to improve the presentation of the paper.

## Conflicts of Interest

The authors declare no conflict of interest.

## References

1. Erdős, P.; Szekeres, G. A combinatorial problem in geometry. Compositio Mathematica 1935, 2, 463–470. [Google Scholar]
2. Bukh, B.; Sevekari, A. Linear orderings of combinatorial cubes. arXiv 2019, arXiv:1906.118669. [Google Scholar]
3. Deorowich, S. On Some Variants of the Longest Increasing Subsequence Problem. Theor. Appl. Inform. 2009, 21, 135–148. [Google Scholar]
4. Gottlieb, E.; Sheard, M. Erdős-Szekeres results for set partitions. Integers 15 2015, 8, A29. [Google Scholar]
5. Romik, D. The Surprising Mathematics of Longest Increasing Subsequences. In Institute of Mathematical Statistics Textbooks, 4; Cambridge University Press: New York, NY, USA, 2015; p. xi+353. [Google Scholar]
6. Stanley, R.P. Increasing and decreasing subsequences and their variants. Int. Congr. Math. 2007, I, 545–549. [Google Scholar]
7. Steele, J.M. Variations on the monotone subsequence theme of Erdős and Szekeres. In IMA Volumes in Mathematics and Its Applications; Springer: New York, NY, USA, 1995; Volume 72, pp. 111–131. [Google Scholar]
8. Xu, X.; Liang, M.; Luo, H. Ramsey Theory: Unsolved Problems and Results; De Gruyter/University of Science and Technology of China Press: Berlin, Germany; Boston, MA, USA, 2018; p. 190. [Google Scholar]