TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A numerical analysis of Quicksort: How many cases are bad cases? [pdf]

35 点作者 edofic超过 9 年前

6 条评论

coherentpony超过 9 年前
If you&#x27;re going to post articles from arxiv, please post the top-level description so I can read the abstract before being forced to download a PDF document.<p><a href="http:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;1507.04220" rel="nofollow">http:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;1507.04220</a>
BetaCygni超过 9 年前
&gt; An attempt to solve this problem has been randomization as shown already in Hoare’s first articles on Quicksort [1]. On the other hand, this does not change the statistical probability for bad cases.<p>I really like the randomization solution. Worst case? What worst case?
评论 #10135594 未加载
Kenji超过 9 年前
I remember, at uni, in the second semester, we had an assignment to specifically craft a sequence of n numbers 1..n that would trigger the worst case (#permutations) in a quicksort algorithm that always takes the first number in the array as the pivot. It was a nightmare. I spent days on it, and I was barely able to scrape together a notation to specify such a series. Turns out the sample solutions were like &quot;The appropriate sequence is not easy to write. The sequence must be designed such that every chosen pivot halves the area that will be stored.&quot; Well, yeah.<p>EDIT: I wrote worst case #permutations. That&#x27;s the best case #comparisons. So, no, I don&#x27;t mean a sorted sequence ;)
评论 #10135732 未加载
评论 #10135754 未加载
评论 #10135918 未加载
评论 #10136174 未加载
rachbowyer超过 9 年前
If Quicksort worst case performance is a problem then use Introsort (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Introsort" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Introsort</a>), which the paper fails to mention.
评论 #10135875 未加载
lsiebert超过 9 年前
It strikes me that, if three way partitioning is useful only if you are dealing with a limited set of values in relation to n, you could hash or insertion sort into an array the values for the first pass of the algorithm over the whole array (stopping if the count of uniques got bigger then some value based on n), and then decide to threeway partition if you hadn&#x27;t stopped.<p>I feel like the recursive median of medians throws away a great deal of information, given all the comparisons you make. At the very least, for the final step, you know where the high and low values go, and could easily place them in the appropriate sides of the array.
coreyp_1超过 9 年前
I love quicksort, and enjoyed the paper. Yes, I&#x27;m a nerd. Thanks for asking.