

Again, back to the former example of Eating burger. Now Consider Burger as Big Computational Problem and Mouth as Processor of Computer. The processor can handle a small part of actual Big Computational problem easily. This type of algorithm which first divide the problem into the small problem until the problem becomes small enough to handle easily called Divide and Conquer Algorithm.
Merge Sort
![]() |
Merging Of Solutions |
Sorting of the array can be done with divide and conquer approach. For sorting of the array, first, we break array into smaller arrays and solve smaller array or break again into smaller arrays and solve them. Here the question is what is the minimum size of the array to be sorted. If we break the main array until all subarrays have one element. We already have sorted array because the array has only one element and In any order ascending or descending one element has its correct position. But the only division of array doesn’t give us the correct output of actual array to be sorted. For having the correct Sorted array of the input array, We have to merge these smaller sorted arrays into the big sorted array until we achieve correct array as output. This algorithm involving the merging of the smaller solution to achieve the Sorting solution, so it is called MERGESORT.
As Merge sort involves breaking and merging of an array. It contains two functions to perform Merge Sort: merge-sort & merge. MergeSort algorithm demonstrate in C/C++ language for Sorting Integers.
Comments
Post a Comment