Merge_Sort - I really don't understand what is happening but my sorting didn't working, I need help, Help Me!
#include<iostream> using namespace std; void merge(int arr[],int start,int mid,int end) { int i=start,j=mid+1,k=0; int temp[10]; while(i<=mid && j<end) { if(arr[i]<=arr[j]) { temp[k++] = arr[i++]; } else { temp[k++] = arr[j++]; } while(i<=mid) { temp[k++] = arr[i++]; } while(j<=end) { temp[k++] = arr[j++]; } for(i=0;i<10;i++){ arr[i] = temp[i]; } } } void mergeSort(int arr[],int start,int end) { int mid = (start+end)/2; if(start<end) { mergeSort(arr,start,mid); mergeSort(arr,mid+1,end); merge(arr,start,mid,end); } } int main() { int arr[10] = {10,35,40,25,21,52,6,20,3,54}; mergeSort(arr,0,9); for(int i=0;i<10;i++) cout<<arr[i]<<" "; return 0; }