Question: When we run mergeSort on an array of 8 elements, how many times MERGE SORT CALLED will be output? Activate Windows public static void
When we run mergeSort on an array of 8 elements, how many times MERGE SORT CALLED will be output? Activate Windows public static void merge(int [] arr, int start, int end) { } System.out.println("MERGE SORT CALLED"); if ( start < end) // general case { int middle = (start + end ) / 2; // sort the left part of the array mergeSort(arr, start, middle ); // sort the right part of the array mergeSort(arr, middle + 1, end); // merge the 2 parts merge( arr, start, middle, middle + 1, end); } // else, base case, empty or 1 element array, already sorted
Step by Step Solution
3.47 Rating (147 Votes )
There are 3 Steps involved in it
The provided images show a typical recursive implementation of the merge sort algorithm albeit with ... View full answer
Get step-by-step solutions from verified subject matter experts
