in reply to Patience Sorting To Find Longest Increasing Subsequence
I found one of the original scientific papers in PDF format (30 pages, 277k), in year 1999, item 2.
On to your questions.
Do the algorithms still work if the original list sorted in ascending order is non-continguous (! 1..N)?Of course they do. All you use for the sorting action, is compare two items. Apart from that, their actual value is never used.
Do the algorithms still work if the original list contains duplicates?Yes, but depending on what you do when they compare the same, your sort might be a stable sort, or not. You would get a stable sort if you treat the current card as the larger one, when they do agree.
Are there ways to maintain the same speed and decrease the memory consumption?If so, I haven't found one.
Would there be a benefit in replacing the linear card placement search with a binary one or would the overhead outweigh the benefit.No idea... In practice, I found binary search often to be slower than linear search, for few items — sometimes not even that few, as I've seen linear search being faster for a search in 500 items.
But we're still stuck with an incomplete sorting.
Perhaps binary search, or rather, a binary tree, could be benificial to complete the sorting: when you have constructed the piles, put (just) the top cards in the binary tree, remove the lowest value from it and from the pile, and insert the next one from the same pile that it came from. Repeat until all piles are expleted and the tree is empty.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Patience Sorting To Find Longest Increasing Subsequence
by Limbic~Region (Chancellor) on May 05, 2006 at 13:02 UTC | |
Re^2: Patience Sorting To Find Longest Increasing Subsequence
by Limbic~Region (Chancellor) on May 05, 2006 at 15:51 UTC | |
by demerphq (Chancellor) on May 06, 2006 at 09:02 UTC | |
by Limbic~Region (Chancellor) on May 06, 2006 at 14:11 UTC | |
by demerphq (Chancellor) on May 07, 2006 at 19:10 UTC |