go to previous page   go to home page   go to next page

Answer:

Yes, it computes the correct value, although it may needlessly examine pairs after it has already found one out of order.

Notice that the > operator is correctly used. Using >= would not work.


Select the Smallest

Here is another list of integers:

Your browser does not support the HTML 5 Canvas.

1. Select the smallest integer in this list and move it into the left-most position.

The original left-most integer is moved into the original location of the integer you moved. (This is different than the previous demonstrations, which behaved more like playing cards.)
After doing this, the left-most single integer is a sorted sub-list.

2. Next, select the smallest integer from the unsorted integers on the right and move it just to the right of the left-most integer.

Now the left two integers are a sorted sub-list.

3. Next, select the smallest integer from the unsorted integers on the right and move it just to the right of the sorted sub-list

Now the left three integers are a sorted sub-list.

Keep selecting the smallest integer from the unsorted right part of the list and placing it just to the right of the sorted sub-list on the left. Soon, the sub-list on the left contains all the integers, which are now sorted. (Click "refresh" in your browser if you want to do this again.)

The idea is to keep growing the sorted list on the left by selecting the smallest integer from the right. Soon, the list of the left contains all integers in sorted order.


QUESTION 8:

This sounds suspiciously like an algorithm for sorting. What do you suppose the algorithm is called?


go to previous page   go to home page   go to next page