Photo of Martin Erwig.

Martin Erwig, professor of computer science, shows his new book, "Once Upon and Algorithm."

"It all started on the bus,” said Martin Erwig of his new book, “Once Upon an Algorithm,” published this year by The MIT Press, which won a 2017 Best Book Award from American Book Fest.

Erwig’s seven-minute commute by bus was the perfect situation to inspire him to boil down computer science for the general public. Discussions naturally developed on those daily bus rides with many of the same people. It could be politics or religion, or sometimes they discussed their work. For Erwig, professor of computer science in the College of Engineering at Oregon State University, the experience was frustrating at times.

“When the discussion got really interesting, we got to my stop and I had to get off,” he said. “I noticed this, and I tried to prioritize and skip over particular aspects to make sure I said the most important things.”

Learn more
- TV interview on KATU
- Radio show: XRAY in the Morning
- Blog post for The MIT Press
- Interview for The MIT Press

But it wasn’t enough. He needed a shortcut to explain abstract computer science topics in a way that would be familiar to people. And he also needed to make it fun so that people would not lose interest and change the subject. His inspiration came when he thought of using the fairy tale “Hansel and Gretel.”

“Computer science is about problem solving, and Hansel and Gretel have a problem — they have to find their way back home,” Erwig said. “And they solve it by executing an algorithm. They follow the path of pebbles which they dropped earlier. This immediately connects with people because they know the story.”

Erwig found that using well-known stories was the shortcut he needed to explain the basic concepts of computer science. In his book, he describes moving from pebble to pebble as a step in the execution of an algorithm. Expanding on that metaphor, he explains concepts such as computation, representation, and termination.

“Hansel and Gretel” was his initial inspiration, but he also uses familiar routines, such as getting ready for work, other books and movies, such as the Harry Potter series, and even the song “Over the Rainbow.”

“Once I decided to use time travel to explain recursion, it had to be ‘Back to the Future.’ There are other good time travel stories, but this one is just great,” he said. He found that writing the book was also a good excuse to watch some favorite movies again.

The intended audience for his book is a broader version of his bus discussion group. It is for people who want to understand more about computer science but have no background in it. Based on reviews in the Times Higher Education, LSE Business Review, and on YouTube, Erwig has hit his mark.

YouTube reviewer Steve Donoghue said, “By the time I finished with the book, I honestly do think I understand the subject, at least on a rudimentary level. And I never would have imagined that would be possible.”

"If you have a rudimentary understanding of computing concepts, then you will be able to follow and participate in the discussions related to computer science."  - Martin Erwig

Readers who want to understand the information at a superficial level can read just the examples, but the hard concepts are also there for those who are interested.

“If you want to really understand it, then you have to read the chapters, and some are a bit tricky,” Erwig said. “I make no apologies for that, because I didn't want to dumb down the topic.”

Although the book was not intended for the classroom, senior instructor Jennifer Parham-Mocello offered to try it in her introductory computer science class. So, this fall, she had graduate teaching student Shannon Ernst use the book with two lecture sections of CS 160. Data collected from the class has yet to be analyzed, but Ernst observed that the book was helpful for many students who lacked programming experience.

Erwig admits it would be exciting if the book were to be more widely adopted at Oregon State, and even by other universities, but he emphasizes that its main purpose is to bring computer science concepts to the general public. He sees this as critical in an age in which huge software challenges impact all of us, such as the approaching reality of self-driving cars.

“Even if you are not a mechanic, you have enough mechanical knowledge to understand the basics. You know what it means when the brakes don’t work,” Erwig said. “If you have a rudimentary understanding of computing concepts, then you will be able to follow and participate in the discussions related to computer science.”