Merge sort recursion

Please check why it isnt working?

#include
using namespace std;

void Merge_sort(int *a, int s, int e){
int m=(s+e)/2;
int j=s;
int k=s;
int i=m+1;
int temp[1000];

for(j<=m && i<=e){
    if(a[j]<a[i]){
        temp[k++]=a[j++];
    }
    else{
        temp[k++]=a[i++];
    }
}
for(j<=m){
    temp[k++]=a[j++];
}
for(i<=e){
    temp[k++]=a[i++];
}
for (int i =s;i<=e;i++){
    a[i]=temp[i];
}

}

void Merge_Sort_rec(int *a, int s, int e){
if (s>=e){
return;
}
int mid=(s+e)/2;

Merge_Sort_rec(a,s,mid);
Merge_Sort_rec(a,mid+1,e);
Merge_sort(a,s,e);

}

int main(){
int n;
cin>>n;

int a[1000];
for(int i=0;i<n;i++){
	cin>>a[i];
}

Merge_Sort_rec(a,0,n-1);

for(int i=0;i<n;i++){
	cout<<a[i]<<" ";
}
return 0;

}

use while loop in merge_sort function. otherwise your code is right.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.