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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

A beautiful algorithm that only a very few know of: In-Place Merge in O(n) time

102 点作者 dhruvbird大约 13 年前

8 条评论

sblom大约 13 年前
This link got me the paper in PDF form with absolutely no hassle: <a href="http://web.eecs.utk.edu/~langston/courses/cs594-fall2003/HL.pdf" rel="nofollow">http://web.eecs.utk.edu/~langston/courses/cs594-fall2003/HL....</a><p>(Appears to be the faculty web site of one of the paper's authors.)
评论 #3638171 未加载
forrestthewoods大约 13 年前
Perhaps very few know of it because it's hidden behind a ridiculous pay wall.
评论 #3638725 未加载
bhickey大约 13 年前
I came across this paper about five years back. At the time I sent an e-mail to Professor Langston thanking him for his insights and clarity in explaining them. Here's his reply:<p><pre><code> Thanks for your kind note Brendan. It's been over twenty years since we wrote that paper. One never knows which works will survive the test of time.</code></pre>
pwg大约 13 年前
Some source - with a lot of comments - that claims to implement the algorithm:<p><a href="http://www.keithschwarz.com/interesting/code/?dir=inplace-merge" rel="nofollow">http://www.keithschwarz.com/interesting/code/?dir=inplace-me...</a>
评论 #3638147 未加载
ggchappell大约 13 年前
There's an issue here that I <i>really</i> don't understand: why is this never used?<p>For example, the original C++ STL generally did a heck of a good job at exposing an interface to the 1997 state of the art in general-purpose algorithms. So, the spec for std::stable_sort was aimed at Mergesort: O(n log n) comparisons and O(n) additional space due to the space required by the Stable Merge. <i>HOWEVER</i>, if limited space is available, then it is allowed to use O(n log n log n) comparisons, since a slower in-place algorithm is used. [1]<p>Why? With the algorithm from this article, we can do an O(n log n) in-place Mergesort. I imagine it's not as fast as the standard algorithm that requires O(n) additional space -- although the abstract of this article does call the in-place merge algorithm "reasonably competitive". But it certainly sounds like it would be a better fall-back option.<p>Similarly, lots of languages have moved toward some version of Mergesort for their standard sorting algorithm: Perl, Python ("Timsort" is a Mergesort variant). Even some versions of the "C" Standard Library's qsort are implemented with Mergesort these days. I never hear about any of these being in-place. But the work in this article isn't exactly a secret.<p>So: I don't get it.<p>[1] EDIT: I checked the C++11 spec. It is the same. std::stable_sort does O(n log n) comparisons if sufficient memory is available, and O(n log n log n) if not.
评论 #3638144 未加载
评论 #3638112 未加载
评论 #3637728 未加载
chmike大约 13 年前
Please do not submit articles behing pay walls.
petercooper大约 13 年前
Being behind a paywall isn't helping with its publicity. On the plus side, this reminds me I really do need to sign up for the ACM! :)
评论 #3637614 未加载
评论 #3637626 未加载
评论 #3637618 未加载
评论 #3637624 未加载
评论 #3641078 未加载
mdonahoe大约 13 年前
Can someone writeup a gist of the algorithm?
评论 #3652334 未加载