Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I AM CODING IN C++. We combine two sorting algorithms, insertion-sort and merge-

ID: 3883285 • Letter: I

Question

I AM CODING IN C++.

We combine two sorting algorithms, insertion-sort and merge-sort, as follows: when the input size is less than 100, we use insertion-sort: otherwise, we use merge-sort. More specifically, we replace line 1 in Merge-Sort (page 34) with "if r - p > = 100", and add line 6 "else lnsertion-Sort(A, p, r)". Insertion-Sort(A, p, r) implies performing insertion sort on the subarray A|p middot middot middot r|. In this lab assignment you will implement this hybrid sorting algorithm.

Explanation / Answer

public class MergeSort { /* Merge Sort function */ public static void sort(int[] a, int low, int high) { int N = high - low; if (N