Merge Sort, Radix Sort, Shell Sort
Merge Sort, Radix Sort, Shell Sort
Ms. P. S. Shete
Assistant Professor CSE
SITCOE, Yadrav
Merge Sort Algorithm
• Merge sort is a sorting technique based on
divide and conquer technique. With Average
case and worst-case time complexity being
Ο(n log n), it is one of the most respected
algorithms.
• Merge sort first divides the array into equal
halves and then combines them in a sorted
manner.
Disadvantages
• Still, there are some tradeoffs for Radix Sort that
can make it less preferable than other sorts.
• The speed of Radix Sort largely depends on the
inner basic operations, and if the operations are
not efficient enough, Radix Sort can be slower
than some other algorithms such as Quick Sort
and Merge Sort.
Ms. P. S. Shete, Asst. Prof, CSE, SITCOE,
13
Yadrav
Disadvantages
• In the example above, the numbers were all of
equal length, but many times, this is not the case.
If the numbers are not of the same length, then a
test is needed to check for additional digits that
need sorting. This can be one of the slowest parts
of Radix Sort, and it is one of the hardest to make
efficient.
• Radix Sort can also take up more space than
other sorting algorithms, since in addition to the
array that will be sorted, you need to have a
sublist for each of the possible digits or letters.
We compare and swap the values, if required, in the original array. After this step,
this array should look like this −
And finally, we sort the rest of the array using interval of value 1. Shell sort uses
insertion sort to sort the array. The step by step depiction is shown below −
Algorithm
• We shall now see the algorithm for shell sort.
• Step 1 − Initialize the value of h
• Step 2 − Divide the list into smaller sub-list of
equal interval h
• Step 3 − Sort these sub-lists using insertion
sort
• Step 4 − Repeat until complete list is sorted
Thank You!!!!!!