This is the half program posted here .I am stuck at this steps and online debugger is not giving correct answers.The whole program gives correct output though. I want to know the value of mid,low and high passed to the second recursive function msort(a,mid+1,high).
Code:
int main()
{
int i,low,high,n,a[10];
printf("how many elements");
scanf("%d",&n);
printf("\nEnter the elements");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
low=0;
high=n-1;
msort(a,low,high);
printf("The sorted array is ");
for(i=0;i<n;i++)
printf("\n%d",a[i]);
return 0;
}
msort(int a[],int low,int high)
{
int mid;
if(low<high)
{
mid=(low+high)/2;
msort(a,low,mid); //Untill here I got right values
msort(a,mid+1,high);// I am stuck over here
}
return 0;
}
After msort(a,low,mid) work is over. According to me,for next function msort(a,mid+1,high) ,
the value of mid is 2 then 3,
the value of low is 3 then 4.
value of high remains 4.
Is this right?
I want to know where I am going wrong.
The value