Stories to support Computational Thinking

The abstract nature of Computer Science has always allowed analogies to be a constant guide. Every concept in computational thinking and algorithm design has parallels in the real world that make it easier for learners to get a better understanding. Both as a teacher and a programmer, I have constantly looked for literature that has supported this. In that line of research I found this interesting book called “Once Upon an Algorithm : How Stories Explain Computing (The MIT Press)” written by Martin Erwig. I am about half way into the book but wanted to document both my learning and some observations from the first few chapters.

The first thing I loved about the book was how it’s table of contents was designed. Instead of being a traditional bulleted list of items, it was a mind map of sorts that showed directional arrows from one topic to another.

Figure 2, Page 11 (Once Upon an Algorithm, 2017)

This design approach allows learners to recognize critical concept dependencies . It also underlines the idea that every chapter has a good reason to be in the book. An approach I hope to see more technical literature follow.

Every chapter in the book is connected to a famous literary piece and the events that unfold within it. For instance, the first two chapters are about how algorithms basically work (step by step instructions that accomplish a task) by using the famous 19th century Brothers Grimm fairy tale Hansel and Gretel. Wanting to get rid of the children, their parents take them deep into the forest and leave them there. But Hansel, already aware of this event, leaves white pebbles along their way so they can find their way back home – which they do. Although the story does not end there, Chapter 1 uses this setting to illustrate both how computational thinking works (Hansel realizing he needed some sort of map to get back home) and how algorithms are designed (Hansel using markers one pebble at a time to get back). The process of Hansel breaking up a big problem (getting home) into smaller problems (finding the next pebble) ties right into the idea of problem decomposition – a primary concept in computing. When introducing algorithms, having students think about reducing the problem rather than the solution is half the battle. Using a story such as this (and almost every fairy tale qualifies!) allows students to connect previous knowledge with new information.

The chapters also get into areas of semantic challenges. Such as, what if Hansel’s route was not as straightforward to be able to recognize the pebbles? Or what if one pebble was so out of range that it made seeing the next pebble impossible? There is nothing telling him how to find the next pebble, right? So, as much as algorithm design is about every single instruction doing something specific (pick up pebble), it is also about recognizing that incorrect outputs are also produced (find next pebble?).

There is also focus on looking at time and space complexities. How many steps would Hansel need to cover to get from one pebble to the next? How many pebbles are there? Since the story says he is a child, does his pocket really have enough space to hold as many pebbles? If not, does he need to go back home every time a new pebble is needed? How does that impact the entire algorithm of him and his sister getting back home? These are important questions for students to critically evaluate the number of things their algorithms are doing and the resources (time and space) they are using to do it. Connecting a story’s elements into computational thinking this way can make both for some fascinating conversations and innovative ways to get Hansel’s story to be a more efficient as a route mapping algorithm.

The second (and last for this post’s purposes) set of chapters I wish to document is the one closer to my heart – Sherlock Holmes! I am an avid reader (as you may have seen from this post) so to see a book combine two of my favorite things – literature and computing – was a rare treat. The book uses Holmes’ methods of deducing meaning from representation of objects he encounters as a way to explain variables and data structures. Using events from stories like The Hound of the Baskervilles and The Valley of Fear, the book gets into concepts of signifier (such as the addition symbol in “a+b”) and signified (adding of two entities). When Holmes encounters signs and symbols during his investigation (a walking stick, paw prints of a hound), he is attaching a representation to it as he goes. The use of data types to hold different pieces of such information is then complimented by the extension into a data structure. Elements from the Baskervilles story are also used to highlight the relevance of lists and other data structures. When Holmes makes a list of suspects, adding, inserting or removing names, he is using a list data structure. While there are several different types of data structures in computing, recognizing the usefulness of having one is the bigger point. An important distinction between a data type and data structure is made.

“While a data type describes requirements of what to do with data, a data structure provides a concrete representation to support these requirements.
“Once Upon an Algorithm,” 2017, Erwig, M

This then leads to consideration of different types of structures (static or dynamic…although with languages like Python implementing lists is becoming easier and more powerful) that need to be considered for a given task. It got me thinking about a data structure to hold all of Holmes’ suspects. A class of some sort that would hold member methods and data to hold information on each suspect. Suspect Name, Motive, Notes, Relevance to case, etc leading to creation of potential Dictionaries. This has potential to become a bigger project once more concepts are covered. Once data volume increases the need for searching and sorting also arrives (covered in later chapters).

Structures such Priority Queues are mentioned in the context of heirs who would benefit from Sir Charles Baskerville’s death. But to better determine how close of a suspect they can be to the death, a tree structure would highlight inheritance details. Comparisons such as these offer a better insight into the concepts because the story is guiding the details.

As I mentioned earlier I am only a few chapters in but I am already seeing the strong foundation teaching/learning computing through stories can have. If Hansel and Holmes feel dated then pretty much any story revolving around collection, organization and interpretation of signs, symbols, messages and events would do. In fact the book even references popular genre titles like Indiana Jones, Game of Thrones and Lord of the Rings to drive home this point. I look forward to the chapter on Recursion that discusses events in Groundhog Day! A second edition perhaps will use more recent examples like Netflix’s Russian Doll.