Ali Almossawi
BRIGHT Magazine
Published in
6 min readMay 8, 2017

--

Illustration by Clinton Campbell for Bright

TTwo years ago, when my daughter was in preschool, she learned about the different jobs people do. She asked me about my job, and I fumbled through an answer about how I made things that you couldn’t really touch and wrote things that not everyone could read (I write computer software). Needless to say, it was a disappointing answer. She knew it. I knew it.

I wanted to come up with a better answer, so I started to look for books and projects and games and toys aimed at introducing computer science to younger people. I began to realize that all but a few of the two dozen or so items on my list were focused on coding — that is to say, they emphasized concepts of program flow or the teaching of a specific programming language. The elementary schools I visited in the San Francisco Bay Area also seemed to focus on coding, and coding alone. Computer science and coding were almost always conflated.

That seemed odd, given that there are concepts in computer science that are both more primal and more timeless, like algorithms, which are these processes that are made up of unambiguous steps and do something useful. The most common, and most literal, analogy that’s given for an algorithm is a recipe.

The analogy I prefer is the decisions we make in everyday life.

How to manage a pile of clothes fresh out of the dryer, how to navigate the aisles in the grocery store, how to decide what music to listen to. And I like that analogy because it shows that this concept of an algorithm can be found everywhere, not only in computing.

The second thing that’s fascinating about algorithms is that they’re rooted in history. Even ancient history. Babylonian tablets from around 1800 to 1600 BCE show that ancient Babylonians wrote down their procedures for determining things like, say, compound interest or the width and length of a cistern given its height and volume, using algorithms. That is to say, their procedures were made up of an unambiguous series of steps: They had some input, some output, they eventually ended and they were useful. And when you look at the works of various contributors to mathematics over the centuries, you find even more examples.

I saw an opportunity to introduce the field of computer science to a younger audience using ideas that didn’t focus on “flow” or “syntax” (qualities associated with coding), but on timeless concepts that are not restricted to a single discipline. And my approach would be similar to my approach to compelling my daughter to eat healthy food: “Hey Dad, this spoonful of mashed potatoes tastes suspiciously like broccoli.” “No idea what you’re talking about, girl.”

When I was in graduate school back in 2006, a professor gave a speech (his name was Randy Pausch and his speech later became the book, “The Last Lecture”). And one of the most vivid metaphors for me in that speech was about how good teaching is, in large part, like a head fake in football. You appear to be moving in one direction, but you actually end up moving in another.

And so, I started to put together 12 scenes from everyday life that explain the fundamental algorithms in computer science.

But rather than focus on the obvious lesson (algorithms), I focused instead on the head fake that would make those algorithms compelling. And that head fake is the comparison.

Comparisons are amazingly powerful. One of the first things children learn are abstractions like big and small, which is why when a child asks, “How tall is that titanosaur that they now have at the Natural History Museum?” it’s less meaningful for the child to hear the response, “Seventeen feet tall, little one,” and more meaningful to hear, “If Ms. Susan, Ms. Margaret, and Mr. Jascha were to stand on each other’s shoulders, Mr. Jascha would probably be able to tickle the titanosaur’s chin.”

What does that have to do with algorithms? That’s the really exciting part. Computer scientists, like their friends in mathematics and systems engineering and probably other disciplines too, compare algorithms all the time to know which is better. And in deciding which is better, they typically look at one to two qualities of efficiency: which algorithm takes less time to complete and which algorithm requires less space to complete.

And so what better way to sell the idea of what an algorithm is than to explain it from a novel vantage point: not by deconstructing it and showing how it works, but by having two algorithms race each other and seeing which makes it to the finish line first. And what better way to make those racing algorithms familiar than to frame them as everyday decisions that a set of characters in 12 stories have to make. I love the depth of that approach.

TTThe ultimate test of the approach’s value was to schedule a meeting with my daughter, who was now five years old. “Remember, back when you were three, you asked me what I did for a living?”

We went through the first story I had come up with, of an au pair who had in front of her a pile of socks and was struggling to figure out how to efficiently match the socks in the pile. I asked my daughter and she said, “Well, what I would do is take a sock from the pile, then look for its match, then put it to one side. Then I would look for another sock, and look for its pair.”

Great. That’s one method. An alternative method would be to take a sock from the pile and put it to one side. Then take another sock from the pile and see if it matches a sock we’ve already put to one side. If so, we match it, and if not, we put it to one side too.

It turns out that the second approach is much more efficient when we have a large enough number of socks because we’re leveraging memory (the line of socks we build on the side), and as a result, we’re reducing the number of socks we have to rummage through.

What are the effects of that one scene? One, it’s interactive. Two, it’s familiar. Three, it introduces some important concepts from computer science (searching, rates of growth, hash tables and memory). And four, it encourages one to think about “why”-type questions rather than “how”-type ones. We don’t care so much about how a search algorithm works, but rather, we care about why it’s more efficient.

Illustration by Alejandro Giraldo

As the interest in K-12 computer science education continues to grow, no doubt influenced by a desire to prepare children for a more demanding labor market, it’s important to not lose sight of the fundamental goal. Why do we want students to gain an appreciation for computer science at an early age? Coding will help them get a job in the immediate future. It’s an invaluable skill. But preparing them for subsequent shifts in the world around them requires that they have an appreciation for deeper concepts. And it’s my contention that algorithms are perhaps the most important of these deeper concepts.

Bright is made possible by funding from the Bill & Melinda Gates Foundation. Bright retains editorial independence. The Creative Commons license applies only to the text of this article. All rights are reserved in the images. If you’d like to reproduce this on your site for noncommercial purposes, please contact us. Follow us on Facebook and Twitter.

This piece was adapted from the preface of “Bad Choices: How Algorithms Can Help You Think Smarter and Live Happier,” published by Viking, an imprint of Penguin Publishing Group.

--

--