Question: On MergeSort: (a) (7%) Explain, using an example, why the Merge Procedure in MergeSort cannot run in-place. (b) (7%) Although MergeSort has a Divide and
On MergeSort: (a) (7%) Explain, using an example, why the Merge Procedure in MergeSort cannot run in-place.
(b) (7%) Although MergeSort has a Divide and Conquer formulation, the actual recursive pseudo-code can be unrolled, so that it can be re-expressed iteratively. Re-write MergeSort using an iterative algorithm, to sort a list of n elements.
(c) (7%) State (but do not prove) a loop invariant for Iterative MergeSort.
(d) (7%) Show that the run-time of Iterative MergeSort is still O(n log n). (e) (7%) In what sense is the variant in (b) more efficient?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
