longest increasing subsequence(O(nlogn))

前端 未结 8 925
花落未央
花落未央 2020-12-07 11:10

LIS:wikipedia

There is one thing that I can\'t understand:

why is X[M[i]] a non-decreasing sequence?

8条回答
  •  半阙折子戏
    2020-12-07 12:14

    There is a proof here https://strncat.github.io/jekyll/update/2019/06/25/longest-increasing-subsequence.html

    basically it is impossible to not be a strictly increasing subsequence. The proof is by contradiction: Suppose it is not then we have two cases: Case 1) There is some element M[j] that ends two subsequences of length j and j+some number. This is impossible (proof in link)

    Case 2) Slightly different that Case 1 but pretty the same reasoning. How can you have a smallest number end two subsequences of two different lengths? it can't be.

提交回复
热议问题