Merge_sort

 __________________💻Merge_sort💻______________

Definition Merge_sort :- Merge sort runs in  0(n log n) time it is a very efficient sorting algorithm with near optimal number of comparison it is best described using a recursive  algorithm. 

" Merge_sort " follows ' divide and  conquer ' approach. 

The algorithm process in 3 steps :-

* if a contains 0 or 1 elements than it is already     sorted otherwise, divide a into two sub - array       number of  equal number elements  . 

* combine the sub - arrays to from a single final       sorted array maintaining the ordering of array 

* conquer means sort the two sub - arrays   recursive using the merge_sort.


 Merge_ sort Images :-

          *This images are assigning order : ⬇️

        



    *Descending order Merge_sort :- ⬇️



    Syntax :-
                         Merge_sort 
                                              {
                                                 int data
                                                                  };
Logic of  Merge_sort :-
            
  Void merge_sort( int a[] , int i, int j) 
    {
       int k ;
       if ( i < j ) 
       {
          K =( i+j) /2;
         mergesort ( a, j, k) ;
         mergesort (a, k+1, j) ;
         mergesort(a, i, k, j) ;
                                         }
                                         }
Output screen images :-

     
















Merge_sort time complexity :-






live programing screen :-

          👁Video👁 

          Ascending order of Merge sort :-



   Descending order of Merge_sort :-




Comments