If you have an array of 8 elements, merge sort works by grouping these 8 into 4 sorted sets of 2. The sort is done through sibling pairs.
With these 4 pairs, you pair these with their siblings and take the first elements of each. Compare element 1 in both and place the lowest value in a third new array. You then compare element 1 with element 2 and place the lowest in the third array. This will go on until you are left with single pair merge sorting into a single final array.
No comments:
Post a Comment