| 57 | } |
| 58 | |
| 59 | void mergesort(int arr[],int l,int r){ |
| 60 | |
| 61 | // l and r defines from where to where we wants to sort. |
| 62 | if(l>=r){ |
| 63 | return; |
| 64 | } |
| 65 | // finding mid |
| 66 | int mid=(l+r)/2; |
| 67 | // sending array to sort from l to mid |
| 68 | mergesort(arr,l,mid); |
| 69 | // sending array to sort from mid+1 to r |
| 70 | mergesort(arr,mid+1,r); |
| 71 | // after the sorted arrays came, merging the two sorted array ,hence division is done first and then succesfully conqure to sort array |
| 72 | merge(arr,l,mid,r); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | int main(){ |
| 77 |