The longest increment subsequence of the algorithm surface question LIS

Source: Internet
Author: User

Find the longest increment sequence O (NLOGN) (not necessarily continuous!)

Reference http://www.felix021.com/blog/read.php?1587%E5%8F%AF%E6%98%AF%E8%BF%9E%E6%95%B0%E7%BB%84%E9%83%BD%E6%B2%A1%E7 %bb%99%e5%87%ba%e6%9d%a5

I just understood his analysis in a more understandable sense.
The title is this d[1..9] = 2 1 5 3 6 4 8 9 7 requires the longest increment subsequence to be found
First, using an array of b[] in order to drop the elements in D into B is used to record the current maximum increment of the subsequence

Throw in 2 to B first
[2] At this time, in the case of an element 2 is known, the longest increment of the subsequence is [2]

Throw in 1
[2 1] found at this time the longest increment of the subsequence is 1 because 2 1 does not constitute an increment
and delete the element that is smaller than the new element added is delete 2
So again [1].

Throw in 5
[1 5]

Throw in 3
[1 5 3] Again there is no increment of the situation said B is used to record the current element increment sub-sequence so b inside should be increment only to
Delete the element that is smaller than the new element added is 5 get [1 3]----at this time the increment subsequence length is 2

Throw in 6
[1 3 6]

Throw in 4
[1 3 6 4]---> [1 3 4]----length 3

Throw in 8
[1 3 4 8]----Length 4

Throw in 9
[1 3 4 8 9]----Length 5

Throw in 7
[1 3 4 8 9 7]----> [1 3 4 7]---length 4

Then the maximum increment subsequence has been found 1 3 4 8 9

The longest increment subsequence of the algorithm surface question LIS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.