A dance of sorts

If you tell somebody to line up ten bottles of different sizes, and then you give them the following instructions to sort the bottles in order of size, pretty much everyone can do it:

(1) Go through the bottles from left to right, swapping any adjacent bottles if they are out of order.

(2) Keep doing step (1) until all the bottles are in order.

The above is the classic Bubble Sort. Here is a lovely YouTube video of a Bubble Sort being performed as a Hungarian folk dance.

But if you say pretty much the same thing in a standard computer programming language, relatively few people can follow:

is_out_of_order = true;

passes = 0;
while ( is_out_of_order )
{
      passes = passes + 1;
      is_out_of_order = false;
     
      n = 0;
      while ( n < 10 - passes )       {             if ( item[n] > item[n + 1] )
            {
                  is_out_of_order = true;
                  swap ( item, n, n + 1 );
            }
            n = n + 1;
      }
}

Somewhere between the Hungarian folk dance and the computer program, comprehension breaks down for most people.

It would be useful to do a careful research study to see just where most people get lost between these two ways of describing a Bubble Sort. The answers might give us better insight into how more people might eventually attain the power to program computers.

Leave a Reply

Your email address will not be published. Required fields are marked *