This is for a assignment, I just want some one to double check before submission please i submitted the top code but my teacher sent it back with the following remarks I have a rewritten version below but as this is my final hange for submission I was hoping some one could please proof it for me

Selection sort pseudo-code

The outer loop repeats the selection process n-1 times. For each iteration it is initially assumed that the first entry (index 0) contains the highest value (max = 0). The inner loop then examines the array from left to right and whenever a higher value is found, it's locations in the list is stored in the value "max".

At the end of the first iteration, the last entry in the list has it's value swapped with the entry containing the highest value. The counter of the outer loop is then decremented

For K= 0 to n-1 Max= 0 For J = 0 to n-K-1 If item (J) > Item (Max) Max = Item (J) End If End For Swap item n-k-1 with Max End for End

Your code has the following expression:

If item (J) > Item (Max)

Max = Item (J)

End If

The algorithm requires the variable “Max” to hold the location or position in the array of the next highest value to be swapped. You are assigning to Max the value stored inside that location in the array.

You also need to show step-by-step how the value stored in Item[n-k-1] with the value stored in location Max. This is requested because data can be lost if a swap is not fully understood.

**I have since changed it to**

for K = 0 to n-1

Max = 0

for j= 0 to n - K-1

if Num[j]> Num[Max]

Max = j

End if

End for

temp = Num[n-k-1]

Num[n-k-1] = Num[Max]

Num[Max] = temp

End for

sorry dont know why the code is all on 1 line there