Soldiers in a Line
Source: Alok Goyal's Puzzle Page
Problem:
In a line up of 10 soldiers, what is the least number of soldiers that can be picked in order of either ascending or descending heights? Assume that no two soldiers have the same height. Soldiers can be picked from anywhere in the line, but their order of standing cannot be changed.
Solution:
Highlight the part between the * symbols for the answer.
* Answer: 4. This is the Erdos-Szekeres theorem: any sequence of (a-1)(b-1) + 1 distinct numbers contains an increasing subsequence of length a or a decreasing subsequence of length b. With 10 = 3*3 + 1 soldiers, some monotone subsequence of length 4 always exists.
Quick proof: label each soldier with (i, d) = (length of the longest increasing subsequence ending at him, longest decreasing one). If two soldiers got the same label, the taller-later / shorter-later comparison would extend one of the two subsequences - so all labels are distinct. If no monotone subsequence had length 4, all labels would lie in {1,2,3} x {1,2,3} - only 9 labels for 10 soldiers, contradiction.
Tightness: the line-up 3 2 1 6 5 4 9 8 7 10 (three decreasing blocks of 3, then the tallest) has longest increasing subsequence 4 and longest decreasing subsequence 3 - so no monotone subsequence of length 5 can be guaranteed, making 4 exact. For general N the answer is ceil(sqrt(N)), with ceil(sqrt(N)) decreasing blocks giving the matching construction.
Solution by the Anonymous commenters citing Erdos-Szekeres / Robinson-Schensted, with the tightness construction from a later comment. *
Problem:
In a line up of 10 soldiers, what is the least number of soldiers that can be picked in order of either ascending or descending heights? Assume that no two soldiers have the same height. Soldiers can be picked from anywhere in the line, but their order of standing cannot be changed.
Solution:
Highlight the part between the * symbols for the answer.
* Answer: 4. This is the Erdos-Szekeres theorem: any sequence of (a-1)(b-1) + 1 distinct numbers contains an increasing subsequence of length a or a decreasing subsequence of length b. With 10 = 3*3 + 1 soldiers, some monotone subsequence of length 4 always exists.
Quick proof: label each soldier with (i, d) = (length of the longest increasing subsequence ending at him, longest decreasing one). If two soldiers got the same label, the taller-later / shorter-later comparison would extend one of the two subsequences - so all labels are distinct. If no monotone subsequence had length 4, all labels would lie in {1,2,3} x {1,2,3} - only 9 labels for 10 soldiers, contradiction.
Tightness: the line-up 3 2 1 6 5 4 9 8 7 10 (three decreasing blocks of 3, then the tallest) has longest increasing subsequence 4 and longest decreasing subsequence 3 - so no monotone subsequence of length 5 can be guaranteed, making 4 exact. For general N the answer is ceil(sqrt(N)), with ceil(sqrt(N)) decreasing blocks giving the matching construction.
Solution by the Anonymous commenters citing Erdos-Szekeres / Robinson-Schensted, with the tightness construction from a later comment. *
If one does not pick any soldiers then the answer is 0. In what way are we picking the soldiers ?
ReplyDeleteReplying to Unknown's comment, If one does not pick any soldiers then the answer is 0 - The question is: what is the largest k such that EVERY lineup of 10 soldiers is guaranteed to contain k soldiers (in their standing order) whose heights are monotone - that guaranteed number is the answer. It is 4 by Erdos-Szekeres. (Reply created using AI)
DeleteAssuming we picker can preprocess the heights before selecting, the least number of soldiers that can be picked in either descending or ascending order would be 2.
ReplyDeletethis scenarios would occur when you pick the first guy as the 5 highest person then try to oscillate between picking the descending and ascending options.
Something like this pattern would occur : /\/\/\/\/
Replying to Vineet Goyal's comment, the least number of soldiers that can be picked in either descending or ascending order would be 2 - The zigzag does not save you: 3,1,4,2,5,... patterns still contain monotone subsequences of length 4 (try listing one). Erdos-Szekeres says any sequence of (4-1)^2 + 1 = 10 distinct numbers has an increasing or decreasing subsequence of length 4 - so the guaranteed answer is 4, not 2. (Reply created using AI)
Delete4. This is essentially asking to prove the Erdos-Szekeres Theorem.
ReplyDeleteIn other words, we want to find the minimum number k such that, for any permutation of 10 elements, we can always either find an increasing subsequence of length k, or a decreasing subsequence of length k.
ReplyDeleteGiven a permutation, we can build a standard Young tableau using the Schensted correspondence:
https://en.wikipedia.org/wiki/Robinson%E2%80%93Schensted_correspondence
This tableau has the property that the length of longest increasing subsequence is the length of the first row (or equivalently, the number of columns), and the length of the longest descreasing subsequence is the height of the first column (or equivalently, the number of lines).
Since a tableau with 10 elements necessarily has either at least 4 lines or at least 4 columns, the number k we are looking for is 4.
More generally, for N soldiers, the numbers is ceil(sqrt(N)).
Is there an algorithm for constructing this permutation ?
DeleteReplying to Unknown's comment, we want to find the minimum number k such that, for any permutation of 10 elements - Beautiful - Robinson-Schensted turns ES into shape combinatorics: a permutation of 10 has a tableau whose shape is a partition of 10, and if both first row and first column had length <= 3 the shape would have at most 9 boxes. Clean proof of tightness too. (Reply created using AI)
DeleteFor any general N,answer is the sequence with ceil(sqrt(N)) decreasing subsequences:
ReplyDelete(ceil(sqrt(N)),1) , (2*ceil(sqrt(N)),ceil(sqrt(N))+1), ....(i*ceil(sqrt(N)),(i-1)*ceil(sqrt(N))+1) .... (N,(ceil(sqrt(N))-1)*ceil(sqrt(N))+1)
which will essentially give maximum ceil(sqrt(N)) sized increasing/decreasing subsequences.
For example,for N=15: 4 3 2 1 8 7 6 5 12 11 10 9 15 14 13
Replying to Unknown's comment, For any general N,answer is the sequence with ceil(sqrt(N)) decreasing subsequences - Correct - the decreasing-blocks-of-ceil(sqrt N) permutation is the standard tightness witness: longest increasing subsequence = number of blocks, longest decreasing = block size, both ceil(sqrt N). For N = 10: 3,2,1,6,5,4,9,8,7,10 has no monotone subsequence of length 5. (Reply created using AI)
Delete