- Find the minimum value in the list
- Swap it with the value in the first position
- Repeat the steps above for the remainder of the list (starting at the second position and advancing each time).
Consider the array list 64,25,12,22,11.
Step 1: Min Value is 11.
64 25 12 22 11
Move it to the first position in the array.
Step 2: Min Value in the rest of the array is 12.
11 25 12 22 64
Move it to the second position in the array.
Step 3:Min value in the rest of the array is 22.
11 12 25 22 64
Move it to the third position in the array.
Step 4:Min value in the rest of the array is 25.
11 12 22 25 64
Its already in the sorted position.
Step 5: It executes one more time.11 12 22 25 64
No comments:
Post a Comment