Sorting Techniques
Criteria of Analysis :
2. Number of swaps
3. Stable
4. In-place
5. Memory used
Comparison based sorts :
1. Bubble Sort - Code
Can get kth largest element
2. Insertion Sort - Code
3. Selection Sort - Code
Number of swaps O(n)
Can get kth smallest element
4. Heap Sort
Additional Note: shiftDown take O(n) time over shiftUp O(nlogn). Ref1, Ref2.
5. Merge Sort
6. Quick Sort
7. Tree Sort
8. Shell Sort
Index based sorts :
9. Count Sort :
Index based sorting. Fastest, Consume a lot of memory.
The biggest advantage of counting sort is its complexity – , where is the size of the sorted array and is the size of the helper array (range of distinct values).
It has also several disadvantages – if non-primitive (object) elements are sorted, another helper array is needed to store the sorted elements. Second and the major disadvantage is that counting sort can be used only to sort discrete values (for example integers), because otherwise the array of frequencies cannot be constructed.
1o. Bucket/Bin Sort : Greek ref
11. Radix Sort
Comments
Post a Comment