Comparison of Complexity Analysis Between Sorting Algorithms
Name | Best Case | Average Case | Worst Case | Memory | Stable | Method Used |
---|---|---|---|---|---|---|
Quick Sort | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | [Tex]n^{2}[/Tex] | [Tex]log n[/Tex] | No | Partitioning |
Merge Sort | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | n | Yes | Merging |
Heap Sort | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | 1 | No | Selection |
Insertion Sort | n | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | Yes | Insertion |
Tim Sort | n | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | n | Yes | Insertion & Merging |
Selection Sort | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | No | Selection |
Shell Sort | [Tex]n log n[/Tex] | [Tex]n^{4/3}[/Tex] | [Tex]n^{3/2}[/Tex] | 1 | No | Insertion |
Bubble Sort | n | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | Yes | Exchanging |
Tree Sort | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | [Tex]n log n[/Tex] | n | Yes | Insertion |
Cycle Sort | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | No | Selection |
Strand Sort | n | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | n | Yes | Selection |
Cocktail Shaker Sort | n | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | Yes | Exchanging |
Comb Sort | [Tex]n log n[/Tex] | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | No | Exchanging |
Gnome Sort | n | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | Yes | Exchanging |
Oddâeven Sort | n | [Tex]n^{2}[/Tex] | [Tex]n^{2}[/Tex] | 1 | Yes | Exchanging |
Introduction to Sorting Techniques â Data Structure and Algorithm Tutorials
Sorting refers to rearrangement of a given array or list of elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of elements in the respective data structure.
When we have a large amount of data, it can be difficult to deal with it, especially when it is arranged randomly. When this happens, sorting that data becomes crucial. It is necessary to sort data in order to make searching easier.
Contact Us