Merge Sort
Mergesort is a sorting technique that also works on the
divide and conquers technique as in the quicksort
technique. In this lesson, we will discuss with you the
working of this merge sort with help of an example. The
first step is dividing the given list into sub-lists and the
second step is merging those sub-lists. C merge sort is a
function merge suit is the array we are going to pass
lower bound and upper bound this is lower bound. If two
elements are there then you're going to divide that
particular list into sub-lists. Then each sub-list is having
only one element and that is the condition you have to
stop dividing you will keep on dividing the sub-list. The
main thing is you have to write down the code for this
merge function that is the backbone of the merge
function and how we are going to merge these arrays.
The code is a recursion call to the left part n to the right
part so this is a call to a recursive call.
Midpoint is midpoint fine so here we call merge sort 0 -
middle element is 0 because 0 plus 1 that is 1 1 divided
by 2 is 0 and then again merge sort 1 to 1 and again we
are going to call merge methadone 0 metal point is lower
bound is 0. This is the recursive tree now how this is
going to be called see first of all massive of 0 to 8 here
we have a first cold would we do this function 0 to 4
again for the first sorting of this one? We are going to call
merge 5 then 5 and then 6 fine lower bound is 5 mid is
also 5 and the upper bound is six now seven 8 7 is less
than this yes this condition is true. We are going to merge
this list with its adjacent list only and when you're going
to draw this recursion tree then you come to know how
we are. merging these sub-lists will be merged this and
Mergesort is a sorting technique that also works on the
divide and conquers technique as in the quicksort
technique. In this lesson, we will discuss with you the
working of this merge sort with help of an example. The
first step is dividing the given list into sub-lists and the
second step is merging those sub-lists. C merge sort is a
function merge suit is the array we are going to pass
lower bound and upper bound this is lower bound. If two
elements are there then you're going to divide that
particular list into sub-lists. Then each sub-list is having
only one element and that is the condition you have to
stop dividing you will keep on dividing the sub-list. The
main thing is you have to write down the code for this
merge function that is the backbone of the merge
function and how we are going to merge these arrays.
The code is a recursion call to the left part n to the right
part so this is a call to a recursive call.
Midpoint is midpoint fine so here we call merge sort 0 -
middle element is 0 because 0 plus 1 that is 1 1 divided
by 2 is 0 and then again merge sort 1 to 1 and again we
are going to call merge methadone 0 metal point is lower
bound is 0. This is the recursive tree now how this is
going to be called see first of all massive of 0 to 8 here
we have a first cold would we do this function 0 to 4
again for the first sorting of this one? We are going to call
merge 5 then 5 and then 6 fine lower bound is 5 mid is
also 5 and the upper bound is six now seven 8 7 is less
than this yes this condition is true. We are going to merge
this list with its adjacent list only and when you're going
to draw this recursion tree then you come to know how
we are. merging these sub-lists will be merged this and