{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

sort2 - In C Merge Sort Uses divide-and conquer methodology...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Merge Sort Uses divide-and –conquer methodology. Main idea: Divide the array into roughly equal sized arrays and sort them separately (it is much easier to sort short lists than long ones). Then merge the two sorted arrays in order to get one sorted array. Trace with: 59 27 80 35 13 75 2 In C: void MergeSort(int List[], int start, int end) { int mid; if (start < end) { mid = (start+end)/2; MergeSort(List, start, mid); MergeSort(List, mid+1, end); Merge(List, start, mid+1, end); } }
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon