I am using arrays in my C project and I am sending this array to sorting algorithms.
For example, I have an array in reverse order. int a[] ={100, 99, 98.......2,1}
It comes to array calculateBasic function properly. And from here I put the first insertionSort () function, it goes here and it ranks 1 to 100 from here.
My problem is that the array I send to the 2nd function insertionSortBinary () is sorted because it is sorted in the first function. I want to send it as the first form that comes to the function.
Here my function code to send sorting algorithms:
calculateBasic(int arr[], int size, int flag)
{
/* int k;
printf("calculateBasic\n");
for(k =0; k<size; k++)
{
printf("%d ",arr[k]);
}
*/
count = 0;
insertionSort(arr, size);
printf("insertionSort count: %d \n", count);
count = 0;
insertionSortBinary(arr, size);
printf("insertionSortBinary count: %d \n", count);
}
The function I created array
createNewReverseList(int size)
{
int *arr;
int j;
int tempSize = size;
arr=(int *)malloc(size*sizeof(int));
for(j =0; j<size; j++)
{
arr[j] = tempSize-j;
}
calculateBasic(arr,size,1);
}