Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part One int numbers = [1, 2, 1, 8, 7, 2, 9, 5, 2, 8]; void sort(int sorting [])

ID: 3748154 • Letter: P

Question

Part One

int numbers = [1, 2, 1, 8, 7, 2, 9, 5, 2, 8];

void sort(int sorting []) {

int n = sorting.length;

for (int place = 0; place < n-1; place++){

int minimum = place;

for (int update = place+1; update < n; update++){

if (sorting [update] < sorting [minimum])

minimum = update;

}

int holder = sorting[minimum];

sorting [minimum] = sorting [place];

sorting [place] = holder;

//end

}

}

1. Show the contents of the array numbers the first time the algorithm reaches the end comment. (so what is the order of the 10 numbers)

2. Show the contents of the array numbers the third time the algorithm reaches the end comment.

3. Show the contents of the array numbers the fifth time the algorithm reaches the end comment.

4. Show the contents of the array numbers the seventh time the algorithm reaches the end comment.

Explanation / Answer

If you have any doubts, please give me comment...

The sorting mechanism here used is Selection Sort

1) 1 2 1 8 7 2 9 5 2 8

2) 1 1 2 8 7 2 9 5 2 8

3) 1 1 2 2 2 8 9 5 7 8

4) 1 1 2 2 2 5 7 8 9 8