I'm trying for a while now to come with an idea to calculate how many longest increasing subsequences there are in a given integer array in the most efficent way. I don't need to find all the subsequences, only how many are they... I'm working with Java. any ideas?
Asked
Active
Viewed 295 times
0
-
2This is a famous known Computer Science problem, Read it Here: http://en.wikipedia.org/wiki/Longest_increasing_subsequence – Orel Eraki Feb 23 '14 at 14:17
-
I know how to get the LIS length, I wan't the number of LIS's. – user3328621 Feb 23 '14 at 14:21
-
Show us what you have so far and why it is not working. – Paul Richter Feb 23 '14 at 14:50
-
It is working, as of now I know how to get the LISs, but I could calculate how many of them are there only after finding them. I want to find how many without finding the LISs. – user3328621 Feb 23 '14 at 15:16
-
You cannot, as you won't determine if a sequence is a LIS without checking all the other sequences. You just ditch the actual found LISs, and store the number of them, along with the length, so that you'll be able to tell if this increasing subsequence is longer (then drop number to 1 and update length), equal (add 1 to number of LISs found) or shorter (ditch it). – Vesper Feb 23 '14 at 16:22