Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

ISBN: 3642412203, 978-3642412202

More Books

Students also viewed these Databases questions