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.
*

Comments

  1. If one does not pick any soldiers then the answer is 0. In what way are we picking the soldiers ?

    ReplyDelete
  2. Assuming 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.

    this 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 : /\/\/\/\/

    ReplyDelete
  3. 4. This is essentially asking to prove the Erdos-Szekeres Theorem.

    ReplyDelete
  4. In 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.

    Given 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)).

    ReplyDelete
    Replies
    1. Is there an algorithm for constructing this permutation ?

      Delete
  5. For any general N,answer is the sequence with ceil(sqrt(N)) decreasing subsequences:
    (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

    ReplyDelete

Post a Comment

Popular posts from this blog

Polya's Urn Problem: Expected Balls in the Smaller Urn

Lion and Man in a Circular Cage: Can the Lion Catch the Tamer?

Expected Tosses for Consecutive Heads: 2 Heads vs 3 Heads Puzzle