I have a question regarding passing address of first element of an array to a (recursive) function:
selectionSort( &b[1], size-1);
When address is passed to a function, function parameter must be a pointer as I know. selectionSort
method gets int b[]
as argument. Not a pointer.
But code works without any problems. Also this code generates subarrays. When we pass the 1st element does it become the subarray's zeroeth element?
void selectionSort(int b[], int size)
{
int temp,i;
if (size>=1)
{
for (i = 0; i < size; i++)
{
if (b[i]<b[0])
{
temp=b[0];
b[0]=b[i];
b[i]=temp;
}
}
selectionSort( &b[1], size-1 );
}
}