9.4 Another good idea for sorting a list is the merge-sort algorithm. It avoids the weakness of...

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: