Challenge: Implement Merge
The merge()
function should merge the sorted subarrays in lowHalf
and highHalf
, and copying lowHalf
and highHalf
.
You should complete the function:
Make it repeatedly compare the lowest untaken element in
lowHalf
with the lowest untaken element inhighHalf
and copy the lower of the two back into array, starting at. Once one of
lowHalf
andhighHalf
has been fully copied back into array, the remaining elements in the other temporary array are copied back into array.
Note: Use indexes
i
,j
, andk
to access elements inlowHalf
,highHalf
, andarray
.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy