# Some ideas for sorting-based activities in K-12

I led a session at CS4Teachers this week. CS4Teachers is a program run by the University of Washington’s Allen School for K-12 teachers in Washington state to see sessions on topics related to CS and CS Education. My session focused on taking some ideas from data structures & algorithms and bringing them down to the K-12 level. Preparing for the session was an interesting challenge, as I’ve only ever taught students at the undergraduate level or above. If you try these activities in a classroom let me know how they go!

For elementary school students (and older ones too!), a great activity is to get them to try binary search. I recommend having them try to find a particular number in a bunch of facedown notecards, then try again with the cards in sorted order. This algorithm is a great takeaway for them for the real world. Try having them find books in a library more quickly by starting in the middle of a row.

For middle school students, having the students sort numbers the way computers do (say, using selection and insertion sorts as starting points) is a great way to emphasize that computers will always do every step, even if it seems silly. Try having them sort an already sorted list with one of the sorts! Another great lesson for students at this age is differentiating between a problem and an algorithm — a single problem can have multiple different algorithms (there’s more than one way to sort a list!) Multiplication by mediation and duplation is another fun example.

For students in AP CS A, taking a day or two (maybe in the time after the AP exam, or right before a break if you’ve just finished a big topic) to cover heaps is a great way to show them a hint of what they get to do at the college level. Heaps are a great way to practice reading and understanding definitions, think about tradeoffs, and compare very different approaches to the same problem.

I talked through all of these in more detail in the session; session slides and this pdf with far more details might help if you want to try to implement these in a classroom.