Блог пользователя X-O__O-X

Автор X-O__O-X, история, 5 лет назад, По-английски

Input: a sequence <A_1, A_2, ..., A_n> of integers and an integer X.

Output: true if there is a strictly increasing subsequence of length X in sequence A, false otherwise.

Is there an O(n) algorithm for this problem ?

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -26 Проголосовать: не нравится

Calculate all $$$a_{i+1}-a_i\ (1\leq i\leq n-1)$$$ and find out if there are $$$x-1$$$ or more continuous positive numbers.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I only have an $$$O(n\cdot log_2(n))$$$ solution using segment tree with coordinate compression + DP. I don't think there is a $$$O(n)$$$ solution. Not sure.

»
5 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

I think if finding LIS of a sequence is lower-bounded by O(nlog(n)), we can prove that we can do no better than O(nlog(n)) in the worst case.

Assume X >= LIS of the sequence. So to check if this length is possible we have to do >= O(nlog(n)) work.

So in worst case O(nlog(n)) is the best we can do.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +16 Проголосовать: не нравится

    Good thought, but this isn't a valid proof. There's plenty of problems where answering "is the answer bigger than or equal to X?" is faster than answering "what is the answer?". Since the latter can be obtained from the former using binary search, a correct lower bound, only knowing the fact that answering "what is the answer?" has a lower bound of $$$O(n \log n)$$$, is $$$O(\frac{n \log n}{\log n}) = O(n)$$$, but this ends up being useless here.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Well technically checking whether the LIS is of length at least X could be faster than calculating the LIS. For example, the problem of checking whether a palindrome of length X exists in a string can be carried out in linear time with hashes, while a binary search + hashes solution takes $$$O(n \; log \; n)$$$ time to compute the longest palindrome. However, the longest palindrome can be computed in linear time with other methods (such as Manacher's algorithm or eertree).

»
5 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

If $$$X \geq | LIS(A) | $$$ means there is such algorithm that find Longest Increasing Subsequence length in Linear. But currently there isnt and continue being researched by some researchers, the best I know is that some papers that prove such $$$O(n\ log(log(n)))$$$ algorithm exists but it is either/both complex or/and having big hidden constant to use in practical