Talk:Quicksort: Difference between revisions
→More examples of Quick Sort in practice: new section |
|||
Line 87: | Line 87: | ||
I am thinking about adding the section on Quick Sort's uses in various fields. While the Quick Sort article provides a comprehensive explanation of the algorithm, it could benefit from more real-world examples of how Quick Sort is used in different domains. For instance, the article could discuss how Quick Sort is used in data processing, image processing , or network analysis, and how it compares to other sorting algorithms in these contexts. This could help readers gain a better understanding of the practical applications of Quick Sort and strengthen it and weaknesses in different settings. [[User:Wpengda|Wpengda]] ([[User talk:Wpengda|talk]]) 23:34, 12 March 2023 (UTC) |
I am thinking about adding the section on Quick Sort's uses in various fields. While the Quick Sort article provides a comprehensive explanation of the algorithm, it could benefit from more real-world examples of how Quick Sort is used in different domains. For instance, the article could discuss how Quick Sort is used in data processing, image processing , or network analysis, and how it compares to other sorting algorithms in these contexts. This could help readers gain a better understanding of the practical applications of Quick Sort and strengthen it and weaknesses in different settings. [[User:Wpengda|Wpengda]] ([[User talk:Wpengda|talk]]) 23:34, 12 March 2023 (UTC) |
||
:Please don't. Applications sections generally turn into spam magnets - long lists of unhelpful trivia. [[User:MrOllie|MrOllie]] ([[User talk:MrOllie|talk]]) 23:41, 12 March 2023 (UTC) |
Revision as of 23:41, 12 March 2023
This is the talk page for discussing improvements to the Quicksort article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
Archives: 1, 2, 3Auto-archiving period: 4 months |
This article has not yet been rated on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||||||||||||||||||||||
Please add the quality rating to the {{WikiProject banner shell}} template instead of this project banner. See WP:PIQA for details.
Please add the quality rating to the {{WikiProject banner shell}} template instead of this project banner. See WP:PIQA for details.
|
| |||
This page has archives. Sections older than 120 days may be automatically archived by Lowercase sigmabot III when more than 5 sections are present. |
Blog interview
The new blog post that purported holds an interview with Tony Hoare isn't needed — most of the history contained in it has already been divulged by Hoare in other places. I'll try to find out where so we can get rid of the blog. QVVERTYVS (hm?)
Lomuto partition scheme
In Lomuto partition scheme implementation there is a mistake. In the worst case scenario j grows as i, giving a memory out of bounds error on the last swap. I correct it, see the history. — Preceding unsigned comment added by Dante DDM (talk • contribs) 23:16, 5 August 2020 (UTC)
- @Dante DDM: No mistake there. The i variable will not be incremented in the last iteration of the loop, so we have 'i is less or equal hi' after the loop termination. No risk of out-of-bounds swap (unless you make a mistake in translating the algorithm into the code). --CiaPan (talk) 23:59, 5 August 2020 (UTC)
- @CiaPan: I've checked out and misunderstood the code. I apologize for bothering. Dante DDM (talk) 11:49, 8 September 2020 (UTC)
- @Dante DDM: That's okay. We all learn from our mistakes. Don't let it to discourage you – It's not the mistake that matters. --CiaPan (talk) 12:35, 11 September 2020 (UTC)
I think the Lomuto partition pseudocode is still wrong. If you partition([2,1],0,1) it will set pivot = 1, i = -1, then on the first loop iteration j=0 and it evaluates A[j] <= pivot or A[0] = 2 <= 1, then in the else it will error trying to swap A[-1] and A[0]. If lo > 0 to start then it will change a value outside of the range. — Preceding unsigned comment added by 75.10.161.2 (talk • contribs)
- Nope. There is no 'else' there, so after the
A[j] <= pivot
comparison which results infalse
there is no 'else' but just another loop iteration. That one ends immediately, becausej = hi - 1
already. So, the control goes to the last three lines, wherei
gets incremented from –1 to 0, thenA[0]
gets swapped withA[1]
and finally the value 1 is returned. --CiaPan (talk) 11:05, 27 July 2022 (UTC)
Wrongly placed reference? & text attribution
1. Reference 16 (at time of writing) is about the Yaroslavskiy algorithm, but it’s placed in the section about the Lomuto implementation. Shouldn’t it be removed there and inserted elsewhere, maybe in the History section?
The reference text (for reference :) Wild, Sebastian (2012). "Java 7's Dual Pivot Quicksort". Technische Universität Kaiserslautern.
2. The algorithm given in the Algorithm section seems to be taken almost verbatim from Yaroslavskiy (Reference 10). Would it be good to attribute it to that paper?
The reference text again: Yaroslavskiy, Vladimir (2009). "Dual-Pivot Quicksort" (PDF). Archived from the original (PDF) on 2 October 2015.
— Preceding unsigned comment added by Geke (talk • contribs) 25 August 2020 (UTC)
Hoare partition scheme does not preserve randomness
The Hoare partition scheme given here is elegant and similar to the one in Hoare's original paper. This algorithm does not swap the pivot element into the "middle" and fix it into its final place. As a result, when sorting a uniformly random permutation, it does not maintain the randomness in the resulting subarrays. As indicated on p. 35 of Sedgewick's PhD thesis "This bias not only makes analysis of the method virtually impossible, it also slows down the sorting process considerably." For example, the average-case analysis given in this article does not apply to this version of quicksort.
If the goal is to show the preferred way to implement a 2-way partition (e.g., fewer exchanges than Lomuto, doesn't go quadratic with all equal keys, provably ~ 2n ln n compares for random permutations), replace Hoare partition scheme with the Sedgewick-Hoare partition scheme, which does swap the pivot element into its final place (and preserve randomness). Alternatively, add a warning in the analysis section that it is not applicable to quicksort with the Hoare partition scheme.
Algorithms4 (talk) 18:20, 7 March 2022 (UTC)
"Quicksort" vs "quicksort"
The article seems to be inconsistent about whether its subject should be capitalised in general usage or not. E.g. currently in the introduction we see the following two usages (my italics): "Efficient implementations of Quicksort are not a stable sort […]", and "Mathematical analysis of quicksort shows that […]". It would be preferable to consistently use one style in the article. — Preceding unsigned comment added by 89.247.165.22 (talk) 13:13, 9 October 2022 (UTC)
Finding pivot - ERROR
There is a an error in finding the mid-point for the pivot.
pivot := A[ floor((hi + lo) / 2) ] // The value in the middle of the array
This is a problem for large values of hi and/or lo. The hi+lo part may overflow the integer type of hi/lo - so you would get a false value.
This should be:
pivot := A[ floor((hi - lo)/2) + lo ] // The value in the middle of the array
This gives the same result, with no risk of overflowing.
Please update - the former code should not be used. 89.134.22.144 (talk) 10:21, 22 November 2022 (UTC)
Adding a Tradeoffs section
Hello, I am thinking about adding a Tradeoffs section to this article to discuss some of the disadvantages of Quicksort. Some of the topics I am thinking about discussing is its lack stability, and what situations where its performance can degrade to O(n^2), and a few other topics. KaiXuanWen (talk) 20:22, 12 March 2023 (UTC)
More examples of Quick Sort in practice
I am thinking about adding the section on Quick Sort's uses in various fields. While the Quick Sort article provides a comprehensive explanation of the algorithm, it could benefit from more real-world examples of how Quick Sort is used in different domains. For instance, the article could discuss how Quick Sort is used in data processing, image processing , or network analysis, and how it compares to other sorting algorithms in these contexts. This could help readers gain a better understanding of the practical applications of Quick Sort and strengthen it and weaknesses in different settings. Wpengda (talk) 23:34, 12 March 2023 (UTC)
- Please don't. Applications sections generally turn into spam magnets - long lists of unhelpful trivia. MrOllie (talk) 23:41, 12 March 2023 (UTC)