Find the longest ascending sub set in an un-ordered set

Go To StackoverFlow.com

0

Given an un-ordered set, such as: 1,2,3,4,0,5,6,7,-1,-2,-3;

Find the longest ascending sub set in it.

The expected result for the above example set is : 1,2,3,4,5,6,7

How to implement it?

2012-04-04 08:18
by smwikipedia
Technically your question is incorrect. Since there's no order in sets, there may not be any "ascending - kirilloid 2012-04-04 08:21
I mean the sub set (sub sequence) is ordered - smwikipedia 2012-04-04 08:31
Then it is an ordered sequence - kirilloid 2012-04-04 08:32


3

This problem is called Longest increasing subsequence and you can read about it here.

2012-04-04 08:21
by Jarosław Gomułka
Thanks. You lead me to the solution, and a great site. Thanks again - smwikipedia 2012-04-04 08:29
I'm glad I could help: - Jarosław Gomułka 2012-04-04 08:32
Ads