Professional Documents
Culture Documents
Merge Sort and Radix Sort
Merge Sort and Radix Sort
It works by recursively dividing the array into two equal halves, then sort
them and combine them.
it gets completed in three steps:
1. Divide: In this step, the array/list divides itself recursively into sub-arrays
until the base case is reached.
2. Recursively solve: Here, the sub-arrays are sorted using recursion.
3. Combine: This step makes use of the merge( ) function to combine the sub-
arrays into the final sorted array.
1. Digits Place: In this step, The list is sorted based on digits’ place
2. Least Significant Bit sort: Initially, the list is sorted based on the Least
significant bit.
3. Most Significant bit: Step2 is repeated up to the most significant bit.
Step 2: Sort the list from the Least significant bit and place it into the
corresponding bucket.
Example:
Pass 1:
In the first pass, the list is sorted on the basis of the digits at 0's place.
After the first pass, the array elements are -
Pass 2:
In this pass, the list is sorted on the basis of the next significant digits (i.e., digits at
10th place).
Pass 3:
In this pass, the list is sorted on the basis of the next significant digits (i.e., digits at
100th place).
After the third pass, the array elements are -