-->

Data Structure: How to implement Merge Sort in C++?

Data Structure: How to implement Merge Sort in C++?
    Merging is the process of combining two or more sorted files into a third sorted file. Merge sort is based on the divide and conquer paradigm. It can be explained as …. Let A[p…..r] is given array with indices p = 1 to r = n. Then steps can be

    Image Source: http://en.wikipedia.org/wiki/Merge_sort
    1. Divide Step: If a given array A has zero or one element, then simply return; it is already sorted. Otherwise split A[p…..r] into two subarrays as A[p….q] and A[q+1…..r] each containing about the half of the elements.
    2. Conquer Step: Conquer by recursively sorted the two sub-arrays A[p….q] and A[q+1….r]
    3. Combine Step: Combine the elements back in A[p…..r] by merging the two sorted sub-arrays into the sorted sequence. Note that: the recursion bottoms out when the sub-array has just one element. So that it is trivially sorted.
    Read more »
    fardi zayden
    @مرسلة بواسطة
    كاتب ومحرر اخبار اعمل في موقع دراسات تقنية .

    إرسال تعليق