简体   繁体   中英

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
c) large in number (>1m)
d) the data are in memory, in a vector
e) they are character arrays
f) I don't care how much memory the algorithm will use

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. It has a complexity of O(n). And you can also very easily parallelise this algorithm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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