Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which sorting algorithms give near / approximate sort sooner?

Which sorting algorithms produce intermediate orderings which are good approximations?

By "good approximation" I mean according to metrics such as Kendall's tau and Spearman's footrule for determining how "far" an ordered list is from another (in this case, the exact sort)

The particular application I have in mind is where humans are doing subjective pairwise comparison and may not be able to do all n log n comparisons required by, say, heapsort or best-case quicksort.

Which algorithms are better than others at getting the list to a near / approximate sort sooner?

like image 803
James Tauber Avatar asked May 27 '09 05:05

James Tauber


People also ask

Which sorting method is the fastest for a nearly sorted list?

Many authors, including Knuth and MacLaren, mention that Straight Insertion Sort is the best sorting algorithm when the list is very nearly in order.

Which algorithm for sorting is the fastest?

If you've observed, the time complexity of Quicksort is O(n logn) in the best and average case scenarios and O(n^2) in the worst case. But since it has the upper hand in the average cases for most inputs, Quicksort is generally considered the “fastest” sorting algorithm.

Which sorting algorithm is faster for sorted array?

Merge sort is more efficient and works faster than quick sort in case of larger array size or datasets. Quick sort is more efficient and works faster than merge sort in case of smaller array size or datasets.

Which sort works faster if data is partially sorted?

Insertion sort is the clear winner on this initial condition. Bubble sort is fast, but insertion sort has lower overhead. Shell sort is fast because it is based on insertion sort. Merge sort, heap sort, and quick sort do not adapt to nearly sorted data.


2 Answers

You may want to check out the shell sort algorithm.

AFAIK it is the only algorithm you can use with a subjective comparison (meaning that you won't have any hint about median values or so) that will get nearer to the correct sort at every pass.

Here is some more information http://en.wikipedia.org/wiki/Shell_sort

like image 173
MartinodF Avatar answered Oct 25 '22 11:10

MartinodF


I would suggest some version of quicksort. If you know in what range the data you want to sort is then you can select pivot elements cleverly and possibly divide the problem into more than two parts at a time.

like image 41
AnnaR Avatar answered Oct 25 '22 13:10

AnnaR