European Union Education and Awareness for Intelligent Systems Bubble Sort

Bubble Sort

This exercise introduces the classical Bubble Sort1 algorithm as an example for how a general algorithm can look like and how it can be used.

Select participants

For the exercise to work there need to be around 6 to 8 students standing in a line as well as one student standing in front of them as the programmer and one as the program. It is a good idea to look for some variety in height for choosing the students in line, as well as making sure they are not already sorted by height.

Provide the algorithm

Hand out the Bubble Sort algorithm sheet to the programmer.

Run the algorithm

The programmer now has to instruct the program on what to do by following the orders on the sheet.

Check the result

When the program ends, all students in the line should be ordered by height.

Discuss what was experienced

Finally it is recommended to talk about what the algorithm did (sorting people by height), how he did it, and if this would work on a different group of students as well (it would). A more advanced question would be if the algorithm could be used for a different purpose and what the programmer would have to change (like sorting names in a telephone book or sorting clothing items by cost).

Material

References

  1. https://www.tutorialspoint.com/data_structures_algorithms/bubble_sort_algorithm.htm