Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> given a sequence of {k^2+1} distinct real numbers, one can find a subsequence of length {k+1} which is either increasing or decreasing

{-2, 1, -1, 1/2, -1/2, 1/3, -1/3, 1/4, … -1/(k/2)} is a sequence of {k^2+1} distinct real numbers, but the longest increasing or decreasing subsequences are of length 2, not k+1.

What am I missing?



Subsequences need not be contiguous. In your example, taking every other number gives the desired monotone subsequence.


The definition of a subsequence is if you have a(n) as a sequence of real numbers and n_1 < n_2 <n_3 < ... is an increasing sequence of integers then

a(n_1), a(n_2), a(n_3), ... is a subsequence of a_n and is denoted a(n_k).

So the indexes don't need to be contiguous, just increasing.

So in your example 2, 1, 1/2, 1/3, ... is a decreasing subsequence.

edit: changed to using function-style notation because the nested subscript notation looks confusing in ascii


Thanks. I was thinking subsequence ~ substring but that’s a false analogy apparently!


Yeah it’s a bit confusing. It’s also confusing when you see them written because they’re actually written usually with a nested subscript. Like

   a
    n
     k
With the k smaller than the n which is in turn smaller than the a. Sequences of all kinds are just a function from the integers to the reals so I don’t know why we had to go and invent a whole new notation for them just to be extra obtuse.


Non-consecutive.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: