高级/非常规高效排序算法
我知道有一些类似:
还有一些不切实际的,例如:
- Bogosort
- RandomSort
上面有些使用比较,有些则不使用。
您知道还有哪些其他有效的数字排序算法或技术吗? 你可以给我推荐一个,即使它在现实生活中不适用或者不切实际,但它必须是有效的,但如果它是一个计算解决方案,那就更好了。
I know there are some like:
- Bubble sort
- Insertion sort
- Shell sort
- Merge sort
- Heapsort
- Quicksort
- Bucket sort
- Radix sort
- Distribution sort
- Shuffle sort
And there are some impractical ones like:
- Bogosort
- RandomSort
Some of the above use comparisons and others do not.
Do you know which other Efficient Algorithms or Techniques for sorting numbers exist?
You can suggest me one even if it is not applicable in real life or it is impractical but it must be efficient, but it would be better if it is a computational solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
意大利面条排序:将意大利面条的长度切成与要排序的数字相对应的长度。然后,你将一捆意大利面条放在桌子上,使它们的所有末端对齐。然后你按顺序选出最长的。设置时间较长,但实际分拣时间恒定。
维基百科有一整套排序算法。
Spaghetti sort: You cut lengths of spaghetti to lengths corresponding to numbers you want to sort. Then you tap the bundle of spaghetti down on the table so that all their ends align. Then you pick out the longest ones in order. The setup time is long, but the actual sorting time is constant.
Wikipedia has a whole category of sorting algorithms.
Python 使用一种名为 timsort 的算法。
Python uses an algorithm called timsort.
有排序网络,如果您事先知道有多少个,这可能是一种有效的排序方式你必须分类的项目。
There are sorting networks, which can be an efficient way of sorting if you know in advance how many items you have to sort.
自然归并排序 与“普通归并排序”有足够的不同,值得单独提及(就像 quickersort 一样,它是快速排序的一个变体,值得一提,但是更是如此)。 Ned 的回答提到的 Python 的 timsort 是基于自然合并排序的,顺便说一句。
哦,还有 Dobosiewicz 排序,又称“梳排序”,它“代表冒泡排序就像 shellsort 代表插入排序一样”(没有什么特别有效的,但仍然值得一提)。
natural mergesort is different enough from "plain mergesort" to be worth mentioning separately (just like quickersort is enough of a variation on quicksort to be worth mentioning, but even more so). Python's timsort, which Ned's answer mentions, is based on natural mergesort, btw.
Oh, and, there's Dobosiewicz sort AKA "comb sort", which "stands to bubblesort as shellsort stands to insertion sort" (nothing especially efficient, but still worth mentioning).
堆排序的一个很好的变体是Smoothsort。如果数据已经几乎排序(O(n) 而不是 O(n log n)),它的性能比 Heapsort 更好。
A nice variation of Heapsort is Smoothsort. It performs better than Heapsort if the data is already almost sorted (O(n) instead of O(n log n)).