In what situations do I use these sorting algorithms?

I know the implementation of most of these algorithms, but I don’t know for which dimensional data sets to use them (and the included data):

  • Combine Sort
  • Bubble Sort (I know, not very often)
  • Quick sort
  • Insert Sort
  • Select Sort
  • Radix Sort
+5
source share
3 answers

First of all, you take all sorting algorithms that are complex O(n2)and discard them.

Then you need to examine a few decencies of your sorting algorithms and decide if each of them will be better suited to the problem you want to solve. The most important are:

? , - (O(1)) . , .

Bubble-sort, Insert-sort Selection-sort . Merge-in-place.

? , x y , x y, x y.

, .

? , .

.

+9

Bubble , . , . " ".

, , . 20-30 , YMMV. , " ", " " " ", "" , .

Sorting Sorting , , - , .

Merge Sort, ( ), , .

, "" Quick Sort , Omega(n^2) , Insertion Sort, - . "" , , "" , , - , . , , , - "IntroSort" - QuickSort, HeapSort.

Radix Sort - . , , (O(n), Omega(n log n)). , , (, 4 32- ), , radix .

+5
  • , , .
  • ,
  • ( )

Note that typically a Merge or Quick sort implementation uses Insertion sorting for parts of a subroutine where the submatrix is ​​very small.

+1
source

All Articles