Why do this problem?
uses the context of sorting playing cards as a hook to engage students' curiosity about efficiency of different sorting algorithms.
The task could be used to introduce the idea of algorithmic complexity, by looking at how long each method takes and considering worst-case scenarios. It could also be used as a programming exercise.
By presenting many different algorithms that perform the same function, we hope students will reflect on the benefits of having a variety of tools in their mathematical toolkit when solving problems.
Each student will need one suit from a pack of cards.
"Shuffle your cards, and then put them in order from Ace to King. Watch how your partner puts their cards in order. Do you both do it the same way? How efficient is your method?"
show students each video
and invite them to make sense of the algorithm and have a go themselves,
hand out this worksheet
for them to make sense of the algorithms on paper.
"For each of the algorithms, perform it a few times to get a feel for it. Then choose two algorithms and compare them. Which is the quickest? Why? Can you put your cards into a worst-case scenario for each of the algorithms, to make it take as long as possible?"
Give students time to explore these, together with the questions from the problem which are on the worksheet:
- On average, which algorithm did you find to be quickest?
- What is the 'worst-case scenario' for each algorithm?
- How long would it take in the worst case?
Then bring the class together to discuss their findings.
Invite students to use pseudocode
, or a programming language if they know one, to express the algorithms.
Introduce the algorithms one at a time. This website
shows visualisations of the different sorting algorithms which might help students to make sense of the different methods.