Implements "patience diff" and the patience algorithm for the longest increasing subsequence problem.
Patience diff
diff :: Ord t => [t] -> [t] -> [Item t]Source
The difference between two lists, according to the "patience diff" algorithm.
An element of a computed difference.
Longest increasing subsequence
longestIncreasing :: [(Int, a)] -> [(Int, a)]Source
Given: a list of distinct integers. Picks a subset of the integers in the same order, i.e. a subsequence, with the property that
- it is monotonically increasing, and
- it is at least as long as any other such subsequence.
This function uses patience sort: http://en.wikipedia.org/wiki/Patience_sorting. For implementation reasons, the actual list returned is the reverse of the subsequence.
You can pair each integer with an arbitrary annotation, which will be carried through the algorithm.