Thread: Confused about "Patience Sorting"

  1. #16
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    But why I not directly use heap sort or tree sort if I can use them?
    *shrug*

    Why not use a general purpose "Quicksort"? Why bother studying "Patience Sort"?

    What algorithm you need to use should be determined by how much you know about the data to be sorted and the characteristics you require.

    I have never studied "Patience Sort". It may be that, as a sorting algorithm, it is useless when compared to any other sorting algorithm. If so, "Patience Sort" would not be the only sorting algorithm useless for sorting. Many "useless" sorting algorithms are of particular use because of the characteristics of how they sort the data.

    Without an extensive study of the performance of the algorithm I have no way of knowing if its characteristics are suitable to sorting a particular "kind" of data.

    I just think patience sort has its own way to do that.
    I did not say that you had to use a tree or heap.

    I also never said that this algorithm was worth implementing.

    Soma

  2. #17
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    But what I want is the "pure" patience sort.
    *tsk*

    Okay.

    Create an array with 2^32 pointers to pointers to your node type and simply use the address as a hash.

    Soma

  3. #18
    Registered User
    Join Date
    Mar 2010
    Location
    China
    Posts
    74
    Well, I don't think this is useful. This may help the speed a little, but it's time complexity is still O(nsqrtn). Because for a randomized array of size (n). The number of piles we get is expected to be (sqrtn). So if we don't use any special method(just like a heap) the the complexity of patience sorting will always be O(nsqrtn).

    In a word, patience sorting is an O(nsqrtn) algorithm, just like a pool sort.

    I won't use this algorithm in real world. I just fond of sorting algorithm which is based on comparison. I have collect about 30 sorting algorithms now.

  4. #19
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by RichSelian View Post
    I won't use this algorithm in real world. I just fond of sorting algorithm which is based on comparison. I have collect about 30 sorting algorithms now.
    Hey, someone else collecting sorting algorithms!
    I've got about 60 array sorting algorithms already myself, and most of them are on my website.
    I also have a program which animates each algorithm, where you can race them against one another (they run in separate threads) and give them different initial sort orders etc.
    See the link in my signature.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #20
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I also have a program which animates each algorithm, where you can race them against one another (they run in separate threads) and give them different initial sort orders etc.
    I was working on something similar a while back. (Some recent developments pushed that project back.)

    Are you doing any benchmarks? Or is this just a visual demonstration? What kind of data do you use?

    Soma

  6. #21
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by phantomotap View Post
    I was working on something similar a while back. (Some recent developments pushed that project back.)

    Are you doing any benchmarks? Or is this just a visual demonstration? What kind of data do you use?

    Soma
    No timing related benchmarks, it only shows the total number of comparisons and assignments for each data set, after the sort completes.

    I also do this cool effect that I saw many years earlier where you sort the pixels of an image. Basically you assign an index to every pixel in the image, from the top left, to the bottom right. Then you randomise that array and sort it whilst periodically drawing where all the pixels are. Depending on the algorithm chosen, the image gradually reappears - very effective with ShellSort.

    I've been meaning to make the whole source of it available for over 18 months now. That and a total redesign of my site...
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to C++ and confused by boolean and ifs and else
    By jconner in forum C++ Programming
    Replies: 10
    Last Post: 08-02-2006, 03:29 AM
  2. Confused about Memory
    By gL_nEwB in forum C++ Programming
    Replies: 22
    Last Post: 06-20-2006, 07:32 PM
  3. Confused
    By (TNT) in forum C# Programming
    Replies: 1
    Last Post: 11-23-2005, 04:49 PM
  4. confused.. in selecting my line of deapth
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-04-2003, 01:21 PM
  5. Extern Question, really confused
    By SourceCode in forum C Programming
    Replies: 10
    Last Post: 03-26-2003, 11:11 PM