Question
descript each lines of each functions void PrintArray(int size, int array []){ for(int i=0; i
descript each lines of each functions
void PrintArray(int size, int array []){
for(int i=0; i printf("array[%d] = %d ", i, array[i] ); } } void swap(int * var1, int * var2){ int temp = *var1; *var1 = *var2; *var2 = temp; } void SelectionSort(int size, int array[]){ int i, j, min_idx; for (i = 0; i < n-1; i++) { min_idx = i; for (j = i+1; j < n; j++) if (arr[j] < arr[min_idx]) min_idx = j; swap(&arr[min_idx], &arr[i]); } } int main() { int data [] = {2, 7, 8, -8, 1, 9, 3, 5}; SelectionSort(sizeof(data)/sizeof(int), data); PrintArray(sizeof(data)/sizeof(int), data); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started