Hi,
i have the code below;
void exchange(int i, int j, int arr[])
{
int k=arr[i];
arr[i] = arr[j];
arr[j] = k;
}
void partition(int low, int high, int pivotpoint, int arr[],int arraysize)
{
int i=0, j=0, pivotitem = arr[low];
j=low;
for(i=low+1;i<=high;i++)
{
if(arr[i] < pivotitem)
{
j++;
exchange (i,j,arr);
}
}
pivotpoint = j;
exchange(low,pivotpoint,arr);
}
void quicksort(int low, int high,int arr[],int arraysize, int pivotpoint)
{
if(high > low)
{
partition(low, high, pivotpoint, arr,arraysize);
quicksort(low,pivotpoint-1,arr,arraysize,pivotpoint);
quicksort(pivotpoint+1,high,arr,arraysize,pivotpoint);
}
}
when partition function job ends,
it values pivotpoint as j,
But when it turns back to quicksort function, the value of pivotpoint is steel zero, while the array is changed as programmed.
why doesn't it change to the new value?