Big O 分析算法
你们发现哪些算法在结果 O 表示法和分析方式的独特性方面具有惊人的(艰难的、奇怪的)复杂性分析?
What all algorithms do you people find having amazing (tough, strange) complexity analysis in terms of both - Resulting O notation and uniqueness in way they are analyzed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我有(相当)几个例子:
I have (quite) a few examples:
阿克曼函数。
Ackermann's function.
这个有点简单,但梳排序让我有点震惊。
http://en.wikipedia.org/wiki/Comb_sort
这是一个非常简单的算法它的大部分内容读起来就像一个过于复杂的冒泡排序,但它的复杂度是 O(n*Log[n])。 我觉得这有点令人印象深刻。
大量的快速傅立叶变换算法也令人印象深刻,证明其有效性的数学是令人迷惑的,尝试自己证明一些算法很有趣。
http://en.wikipedia.org/wiki/Fast_Fourier_transform
我可以很容易地理解素数基数、多个素数基数和混合基数算法,但适用于大小为素数的集合的算法非常酷。
This one is kinda simple but Comb Sort blows my mind a little.
http://en.wikipedia.org/wiki/Comb_sort
It is such a simple algorithm for the most part it reads like an overly complicated bubble sort, but it is O(n*Log[n]). I find that mildly impressive.
The plethora of Algorithms for Fast Fourier Transforms are impressive too, the math that proves their validity is trippy and it was fun to try to prove a few on my own.
http://en.wikipedia.org/wiki/Fast_Fourier_transform
I can fairly easily understand the prime radix, multiple prime radix, and mixed radix algorithms but one that works on sets whose size are prime is quite cool.
2D有序搜索分析相当有趣。 您有一个由 NxN 组成的二维数值数组,其中每行从左到右排序,每列从上到下排序。 任务是在数组中找到特定的数字。
递归算法:选取中间的元素,与目标数进行比较,丢弃数组的四分之一(取决于比较的结果),递归地应用到剩余的 3 个四分之一,分析起来很有趣。
2D ordered search analysis is quite interesting. You've got a 2-dimensional numeric array of numbers NxN where each row is sorted left-right and each column is sorted top-down. The task is to find a particular number in the array.
The recursive algorithm: pick the element in the middle, compare with the target number, discard a quarter of the array (depending on the result of the comparison), apply recursively to the remainig 3 quarters is quite interesting to analyze.
非确定性多项式复杂性得到了我的投票,特别是考虑到它可能与多项式相同的可能性(诚然被认为不太可能)。 同样,任何理论上可以从量子计算中受益的东西(注意这组绝不是所有算法)。
我投票的另一个问题是对任意精度数字的常见数学运算——在这里你必须考虑诸如乘以大数比乘以小数更昂贵的事情。 Knuth 对此有相当多的分析(这对任何人来说都不是什么新闻)。 唐叶的方法非常简洁:将两个因数按数字减半(A1;A2)(B1;B2),然后分别乘以A1 B1、A1 B2、A2 B1、A2 B2,然后将结果组合起来。 如果需要的话可以递归...
Non-deterministically polynomial complexity gets my vote, especially with the (admittedly considered unlikely) possibility that it may turn out to be the same as polynomial. In the same vein, anything that can theoretically benefit from quantum computing (N.B. this set is by no means all algorithms).
The other that would get my vote would be common mathematical operations on arbitrary-precision numbers -- this is where you have to consider things like multiplying big numbers is more expensive than multiplying small ones. There is quite a lot of analysis of this in Knuth (which shouldn't be news to anyone). Karatsuba's method is pretty neat: cut the two factors in half by digit (A1;A2)(B1;B2) and multiply A1 B1, A1 B2, A2 B1, A2 B2 separately, and then combine the results. Recurse if desired...
贝壳排序。 有大量具有不同增量的变体,其中大多数除了使 复杂性分析更简单。
Shell sort. There are tons of variants with various increments, most of which have no benefits except to make the complexity analysis simpler.