Hand Algorithms

Exercise: each team gets a deck of 13 playing cards, all from one suit; your task is to sort them from low to high. First we have to constrain ourselves to a few simple operations. We can count the cards. We can look at a card and recognize its value. We can remember one card at a time - both its value and its location. We can compare the value of a remembered card and another card. We can swap the position of two cards.
Thus, we can do things like look at a card, compare it to it's neighbor to the right, swap them if the first is larger than the second.
We will, in version one of the exercise, count comparisons and swaps.
First, spread your cards out and come up with a strategy for sorting them.

Questions

  1. What ordering system did you use?

Reading Have a look at the Wikipedia article on Sorting.