Selection sort: Difference between revisions

Content deleted Content added
Tag: Reverted
Restored revision 1172462374 by Materialscientist (talk)
Line 27:
! Least element in unsorted list
|-
| [ ]()
| style="text-align:right;" | [(11, 25, 12, 22, 64])
| 11
|-
| [ (11])
| style="text-align:right;" | [(25, 12, 22, 64])
| 12
|-
| [(11, 12])
| style="text-align:right;" | [(25, 22, 64])
| 22
|-
| [(11, 12, 22])
| style="text-align:right;" | [(25, 64])
| 25
|-
| [(11, 12, 22, 25])
| style="text-align:right;" | [(64])
| 64
|-
| [(11, 12, 22, 25, 64])
| style="text-align:right;" | [ ]()
|
|}
Line 82:
/* a[0] to a[aLength-1] is the array to sort */
int i,j;
int aLength; // initialise to a's lenglength
 
/* advance the position through the entire array */
/* (could do i < aLength-1 because single element is also min element) */
for (i = 0; i < aLength-1; i++)
{