In this activity, the students receive cards with numbers and demonstrate sorting algorithms by sorting themselves.
| Parameters: | |
|---|---|
| Duration: | 20 minutes |
| Participants: | 12–24 students |
| Instructors: | 1 teacher |
| Class: | anywhere with enough space to move around |
| Resources: | printed cards with numbers |
| Prerequisites: | the concept of a variable, list, algorithm |
- Understand the principle of selected sorting algorithms (in this case, Bubble Sort and Selection Sort).
- Code the algorithms in a chosen programming language.
- Print the number cards and cut them. Use one-sided printing.
- Briefly explain how Bubble Sort works.
- [Modification] Instead of you explaining the algorithms, you can select one student from each group who will become a 'captain' of his/her group and brief the group about how the algorithm works (essentially peer tutoring).
- Divide the whole class into two roughly even groups, A and B, each with at least 6 people.
- The members of the group A will act as variables in an unsorted list. Every student from the group A randomly draws one number and lines up in front of the class showing his/her number to the class. Check quickly that the order is unsorted and that it will allow demonstrating the algorithm adequately.
- [Optional] Mark the places on the floor for each 'variable' with a tape or chairs, at least for the first and the last element of the list.
- [Modification] You can have the students hide their number cards to prevent someone from 'cheating' and looking at all the numbers at once. The 'processor' will have to ask the student what his/her number is, simulating reading of only one value at a time.
- Select a volunteer from the group B who will act as a 'processor' and will try to sort the 'variables'. Remind him/her that only one value can be processed at the time, as people tend to look at all the numbers and sort them in their head.
- [Modification] The 'processors' from the group B can change after each step of the algorithm.
- Check on the progress of the group B. If the current 'processor' makes a mistake, encourage other students from group B to correct him/her.
- When the list is sorted, swap the groups (so that the 'variables' become 'processors' and vice versa) and perform the same activity for Selection Sort.
- When the class understood both algorithms, have each student individually decide which algorithm (s)he finds easier and let him/her code it. Leave the other algorithm as a homework assignment.
- You can modify this activity so that group A has to demonstrate the algorithm without words while group B watches and then has to execute the algorithm again.
- Wikipedia has an excellent comparison and explanation of various sorting algorithms.
Michaela Pokludová, Valdemar Švábenský, 2016.