Question: 9.4 Another good idea for sorting a list is the merge-sort algorithm. It avoids the weakness of quicksort that occurs when lists Small and Big

9.4 Another good idea for sorting a list is the merge-sort algorithm. It avoids the weakness of quicksort that occurs when lists Small and Big happen to be of very different lengths. Merge-sort is based on dividing the list, then sorting smaller lists, and then merging these sorted smaller lists. Accordingly, to sort a list L: divide L into two lists, L1 and L2, of approximately equal length; sort L1 and L2 giving S1 and S2; merge S1 and S2 giving L sorted. The complexity of merge-sort is of the order n log n. Implement merge-sort and compare its efficiency with the quicksort program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Management And Artificial Intelligence Questions!