Using the answer provided here, I am now trying to find the longest increasing subset in two different sequences of numbers defined by location1 and location2.
For each location there are 16 readings. Each reading has its own position. I have sorted both lists by the Reading column.
Using a Scatter-Plot graph for each location, I am trying to find the longest increasing subset
Location 1
Location 2
Based on the two graphs; for location 1 the length of the longest increasing subset is 7 (7 positions) and for location 2 it is 5.
I highlighted the longest subsequence I found using the graph in blue and Itzik's subsequence in red.
The problem is that the book that I took these two lists from TSQL Querying (Itzik Ben-Gan) indicates that the longest increasing subset for Location2 has 6 points and using the graph, I only found 5 points that make up the longest subset.
Here is the longest subset according to the book
As you can see the readingNum column is out of order. My assumption was that to find the longest increasing subset, the position in the array had to increase as well as the value of that position.
Questions:
What is the longest increasing subsequence for both locations?
What is the formula, algorithm or method used?
Thanks