Selection Sort Demonstration

THE ALGORITHM:

Set marker U to the beginning of the list

REPEAT WHILE U does not point to the last cell

set SMALLEST to the value that the cell U points to

set marker C to the position of U

REPEAT WHILE C points to a valid cell

IF the value at C is less than SMALLEST THEN

set SMALLEST to the value at C

END IF

move C one cell to the right END REPEAT

SWAP the contents at U with the contents of the SMALLEST cell

move U one cell to the right END REPEAT

    STOP

1 2 3 4 5 6 X  
MARKERS SMALLEST
VALUES


Last updated 05/06/2001 | © 2001, Chris Harwood