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
Get step-by-step solutions from verified subject matter experts
