Answer to Question #109039 in Math for Gnanamani CT

Question #109039
Sort the given list of elements using Merge sort
4,2,7,1,9,12,11,10
1
Expert's answer
2020-04-14T16:43:34-0400

In merge sort, we break the given array midway. (step 1)

We have 2 subarrays: [4, 2, 7, 1] and [9,12,11,10]

Then we divide these 2 subarrays again. (step 2)

We have 4 subarrays: [4,2], [7,1], [9,12], [11,10]

And so on till we have subarrays with single element. (step 3)

We have 8 subarrays: [4], [2], [7], [1], [9], [12], [11], [10]

We start merging the subarrays:

we have 4 sorted subarrays with 2 elements (step 4)

They are [2,4], [1,7], [9,12], [10,11]

2 sorted subarrays with 4 elements (step 5)

They are [1,2,4,7] and [9,10,11,12]

And finally we have a sorted list of numbers (step 6)

Result: [1,2,4,7,9,10,11,12]





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment