The upper bound on the algorithm can't possibly be true! How can it be a comparison sort, and have less than O(n log n)? It's not possible! gkhan 12:34, May 28,
This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects:
This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.ComputingWikipedia:WikiProject ComputingTemplate:WikiProject ComputingComputing
This article has been automatically rated by a bot or other tool because one or more other projects use this class. Please ensure the assessment is correct before removing the |auto= parameter.
This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.Computer scienceWikipedia:WikiProject Computer scienceTemplate:WikiProject Computer scienceComputer science
Latest comment: 14 years ago2 comments2 people in discussion
The upper bound on the algorithm can't possibly be true! How can it be a comparison sort, and have less than O(n log n)? It's not possible! gkhan 12:34, May 28, 2005 (UTC)
I agree with the O(n log n) limit. The algorithm as described seems to have complexity O(n * m), where m is the length of the longest ordered subsequence. I'm not sure what the expected value of m is, but its worst-case is clearly n (if the array is already sorted), making the algorithm O(n^2). I'm not sure how the van Emde Boas tree fits in.
I asked a question about this on comp.programming where I got a satisfactory explanation [1]gkhan 19:47, May 29, 2005 (UTC)
Good call. By that argument, the worst case on gathering is O(n log n). One would think that the complexity to deal would be the same, but in fact you can simply keep track of the largest element seen so far, making sorted input O(n). Bovlb 02:42, 2005 May 30 (UTC)
The van Emde Boas based implementation makes asumptions about the keys range so it is not a comparison sort. Lets talk of arbitrary values and true comparison sorts. Using binary search to build the piles gives a O(n log n) algorithm. For gathering, the wikibooks implementation is not really efficient since it consist of an inteleaving of all the piles (the number of piles can be ) and this can cost comparisons (take as initial list). A better implementation can use and preserve the fact that the top of piles are ordered. We can surely do that by insertion of the first pile in the ordered list of piles with respect to the top values ordering, however this will also cost . Of course, to gather one can forget the structure and apply a sort at this point, but this can't be called a patience sort. PierreBoudes15:07, 16 March 2007 (UTC)Reply
I think thats exactly the point. Why generating piles and then use a Priority queue like in the Java implementation? You could just use a Priority queue in the first place and don't use the piles. It's like I invent a new sort algorithm named reverseSort: reverse the Input and then use a priority queue. And it just needs time, wow! Popelmaus (talk) 16:03, 25 April 2012 (UTC)Reply
Removed from article
Latest comment: 20 years ago2 comments2 people in discussion
(To play with a regular 52-card deck, some ordering needs to be imposed, arranging the cards within a suit and imposing some order on the suits).'
I feel that some context introduction is needed; when one is describing a card game, it only makes sense to explain how to play with the regular cards. Even the article [1] doesn't snub the idea of explaining it to the regular card players:
To play with real cards, one needs to linearly order the 52 cards, e.g., by putting suits in the bridge-bidding order . This mindless form of solitaire is then quite playable, perhaps while watching television.
Latest comment: 15 years ago3 comments2 people in discussion
Since there seems to be no free software implementation of the patience sorting available, I finally got to posting one myself, in C++ [2]. Currently no veb-trees are implemented, as well as no back-pointer-based sorting recovery, but it's what I myself use for a quick check of what the longest increasing subsequence length in a set is. Comes with some other C++ utilities you might like. --BACbKA13:34, 12 May 2006 (UTC)Reply
Thanks to User:Egkauston, who pasted a java implementation, I decided to proceed in a more fundamental way and created a patience sorting page on the wikibooks. The java code has been moved over there, and I have pasted excerpts from the above C++ code as well. See the wikibooks link in the article. --BACbKA23:52, 1 February 2007 (UTC)Reply
Hi, I fixed the C++ code because it used a static function in an empty class. I understand why it's necessary in Java but it is not in C++ : you can use "global" function. Other than that, I was thinking that this function could be adapted in a STL Algorithm stype by using iterators only instead of a vector but it depends on if the algorithm requires random access to elements. That said, it's only an example so it might not be necessary to do that (and maybe make it less obvious to non-C++ programmers ) Anyway I didn't touch the inside of the code. 213.39.33.80 (talk) 12:31, 24 November 2010 (UTC)Reply
bazaar
Latest comment: 10 years ago3 comments3 people in discussion
I wonder if the fact that bazaar uses patience sort is notable enough in general (if it were, why isn't it on the bazaar article)? If it's notable in the context of the "Patience sorting" article, maybe we should create a new section detailing usage examples in known programs? if yes, what to call it? The reason I am asking is that, currently, I find the bazaar link in the "See also" section a bit sticking out of the general flow of the article, and have no trivial way in mind to smoothen it back. --BACbKA07:46, 8 February 2007 (UTC)Reply
Latest comment: 10 years ago2 comments2 people in discussion
A whole section devoted to a card game, but no real description of the problem? And why C++ for implementation instead of pseudo-code or some more concise language? —Preceding unsigned comment added by 95.181.12.52 (talk) 14:02, 8 June 2010 (UTC)Reply
Latest comment: 1 month ago1 comment1 person in discussion
In the info box, there is a field "Optimal" that is marked "?" (note that this field isn't present in all sorting algorithms' info boxes). The worst case runtime for patience sort is O(nlogn), while the best case is O(n), which means it must be optimal in the general case due to the information theoretic lower-bound on comparison sorts.
Does optimal have some other meaning here, and if so, what is it, and can we make this field more descriptive?
Here is a quick survey of how optimal shows up in some other (comparison-based) sorting algorithms' info boxes:
Also in line with O(nlogn) worst case being optimal, as if the input is not balanced, the runtime is O(n^2), but if it is, the runtime is O(nlogn). Best case performance is O(nlogn), so it doesn't match the idea of "optimal" being optimal worst case and optimal best case.
This has a worst case O(n^2), but the "?" could be interpreted as "we don't know if there is an O(nlogn) version of this algorithm" (I don't know if this is actually an open question, I had never heard of this before today and didn't look into the algorithm). But for patience sorting, we do know there isn't a o(nlogn) algorithm for patience sorting due to the information theoretic lower bound.
Cycle sort: "Optimal : Yes, in terms of the total number of writes to the original array"
This one is a totally different version of optimality, since it is inplace. The runtime is O(n^2), but it is optimal in the number of writes to the input, which is not the same as the standard definition of "optimal" for runtime complexity.
The other sorts either have nothing listed, or are in line with Optimal meaning "O(nlogn) worst case".
So, I propose marking this as "Optimal : Yes" or just removing this field altogether from sorting algorithms since it is redundant when the worst-case runtime is in the info box. For Cycle sort, the intro paragraph explains this version of optimality, so I think it is not helpful in that info box either.
When I read "Optimal : ?" I think that the (non)optimality is unknown (which again is not the case for patience sort). If this is what is intended, then just writing "Optimal : unknown" would be more clear, imo.
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.