Sorting Algorithms with Poker Cards

Some time ago, I needed my class to gain a basic understanding of sorting algorithms. After all, sorting is a classic in algorithmics that allows to consider many aspects (time complexity/memory usage). On the other hand, in practice all of them could rely on existing implementations in their daily life.

Thus I decided to let the students do the sorting with poker cards instead of computers.

Required material

  • four piles of 20 playing cards
  • printed pseudocode of the four sorting algorithms
  • stopwatches (any mobile phone will do).
  • paper to write down time

How to do it

  • organize the material in four stations (each with a set of cards and one sorting algorithm)
  • divide the class into groups
  • ask them to cycle the stations, follow the instructions and measure time.
  • Optional: repeat the procedure with a small (10) and a larger (20) number of cards to get an idea of time complexity.

The instructions

Selection Sort

  1. Shuffle the cards.
  2. Lay them out in a row in front of you.
  3. Take the smallest card an put it on a separate pile.
  4. Look for the next smallest card and put it on top of the first.
  5. Repeat steps 3.and 4. until all cards are sorted.
  6. Measure the time you need for sorting all cards and write it down.

Insertion Sort

  1. Shuffle the cards.
  2. Place them in a pile in front of you.
  3. Take the first card into your hand.
  4. Take the second card and put it next to the first, so that the smaller one is to the left.
  5. Take the next card and put it into the correct position beside the others.
  6. Repeat step 5. until all cards are sorted.
  7. Measure the time you need for sorting all cards and write it down.

Bubblesort

  1. Shuffle the cards.
  2. Lay them out in a row in front of you.
  3. Look for a smaller card that is on the right adjacent to a bigger one.
  4. Exchange the two so that the smaller card is to the left.
  5. Repeat steps 3. and 4. until everything is sorted.
  6. Measure the time you need for sorting all cards and write it down.

Mergesort

  1. Shuffle the cards.
  2. Divide them into two equal piles.
  3. Sorts both piles separately in your hand.
  4. Place the sorted piles face up in front of you, so that the smallest card is on top.
  5. Place the smaller of the two visible cards on a third pile.
  6. Repeat step 5. until all cards are in the third, sorted pile.
  7. Measure the time you need for sorting all cards and write it down.

Download printable PDF

Download editable document

Blog Topics

Tags

See also