DS – Merge Soft Algorithm

Merge Sort

  • A sorting technique is used to arrange the elements in a sorted order.
  • Like Quick Sort, it is also a Divide and Conquer algorithm.
  • In Merge Sort, First we divide the input array into two halves recursively.
  • We sort the divided halves individually and merge them quickly.

Work Flow:

Algorithm for Merge Sort:

mergeSort(low, high)
{
            if(low < high)
            {
                        mid = (low+high)/2;
                        MergeSort(low, mid);
                        MergeSort(mid+1, high);
                        Merge(low, mid, high);
            }
}

Sorting after split:

Now remaining elements in array A should be moved to Array C

Algorithm:

Scroll to Top