Saturday, January 3, 2015

Selection sort


Psuedocode

For i = 0 to N
     int min = i
     For j = i to N
           if array[j] < array[min]
              min = j
     Swap min with i

English
For each position in the array, find the smallest item to the right and swap it into the position. After each pass the array will be partially sorted to the left of the position.

No comments:

Post a Comment

There was an error in this gadget