Home / Expert Answers / Computer Science / consider-the-pseudocode-description-of-an-implementation-of-the-merge-sort-algorithm-below-given-th-pa289

(Solved): Consider the pseudocode description of an implementation of the merge sort algorithm below.Given th ...



Consider the pseudocode description of an implementation of the merge sort algorithm below.

student submitted image, transcription available below

Given the initial call mergeSort([16, 63, 24, 76, 30, 67, 96, 15, 41, 66]), complete the chart below by giving the values of the following entries of each array immediately after the indicated call to merge. [Note: If an array has only one entry, then the entry is both the first and last entry of the array.]

student submitted image, transcription available below
Algorithm: merge(data , first , second Input: data - the array of size first - contains sorted elements second - contains sorted elements Result: The array data is sorted. iFirst iSecond while ifirst < size1 AND iSecond < size2 do if first [iFirst] < second[iSecond] then data[j] first [iFirst] iFirst iFirst +1 else data second[iSecond] iSecond iSecond +1 end end rangeCopy(first,iFirst,data,j,(n-1)/2+1-iFirst) rangeCopy(second,iSecond,data,j,n-(n-1)/2-1-iSecond) Algorithm 2: Merge Two Sorted Halves into data Algorithm: mergeSort(data[0 Input: data - the array to be sorted Result: The elements of data are in non-decreasing order. if size then first allocate(mid+1) second allocate mid-1]) rangeCopy(data, 0 ,first, 0, mid+1) rangeCopy(data,mid+1,second,0,n-mid-1) mergeSort(first, mid+1) mergeSort(second,n-mid-1) merge(data,first,second) deallocate(first) deallocate(second) end Algorithm 1: Copies data into Two Arrays - irst and second A. After the third call to merge, the first entry of first is the last entry of first is , the first entry of second is the last entry of second is the first entry of data is and the last entry of data is B. After the fifth call to merge, the first entry of first is the last entry of first is , the first entry of second is the last entry of second is , the first entry of data is and the last entry of data is C. After the seventh call to merge, the first entry of first is , the last entry of first is , the first entry of second the last entry of second is the first entry of data is , and the last entry of data is D. After the ninth call to merge, the first entry of first is the last entry of first is the first entry of second is the last entry of second is the first entry of data is , and the last entry of data is


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe