简体   繁体   English

针对唯一数据的排序算法

[英]Sorting algorithms for unique data

What sorting algorithms perform better than quicksort when the data being sorted are: 当排序的数据是:时,排序算法比快速排序更好地执行:

a) unique 一个特别的
b) in completely random positions b)完全随机的位置
c) large in number (>1m) c)数量多(> 1m)
d) the data are in memory, in a vector d)数据在向量中的内存中
e) they are character arrays e)它们是字符数组
f) I don't care how much memory the algorithm will use f)我不关心算法将使用多少内存

I understand, this kind of question can have many variables, so I tried to provide as many information I could. 我明白,这类问题可能有很多变数,所以我试图提供尽可能多的信息。

Since you have character arrays and don't care about memory (although, you do are limited by the hardware memory available, so I don't know how you can not care) you can use Radix sort. 既然你有字符数组并且不关心内存(虽然你确实受到可用硬件内存的限制,所以我不知道你怎么不关心)你可以使用Radix排序。 It has a complexity of O(n). 它具有O(n)的复杂性。 And you can also very easily parallelise this algorithm. 您还可以非常轻松地并行化此算法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM