C Program For Insertion and Selection
C Program For Insertion and Selection
#include<stdio.>
int min_idx = i;
min_idx = j;
// correct position
arr[i] = arr[min_idx];
arr[min_idx] = temp;
printf("\n"); }
int main()
printArray(arr, n);
selectionSort(arr, n);
printArray(arr, n);
return 0;
}
// C program for implementation of Insertion Sort
#include<stdio.h>
int j = i - 1;
/* Move elements of arr[0..i-1], that are greater than key, to one position ahead of their current position
*/
arr[j + 1] = arr[j];
j = j - 1;
arr[j + 1] = key;
printf("\n");
} // Driver method
int main()
insertionSort(arr, n);
printArray(arr, n);
return 0;