Skip navigation
Hardcover | $27.95 Trade | £22.95 | 336 pp. | 7 x 9 in | 99 b&w illus. | August 2017 | ISBN: 9780262036634
eBook | $19.95 Trade | August 2017 | ISBN: 9780262341684
Mouseover for Online Attention Data

Once Upon an Algorithm

How Stories Explain Computing


Picture a computer scientist, staring at a screen and clicking away frantically on a keyboard, hacking into a system, or perhaps developing an app. Now delete that picture. In Once Upon an Algorithm, Martin Erwig explains computation as something that takes place beyond electronic computers, and computer science as the study of systematic problem solving. Erwig points out that many daily activities involve problem solving. Getting up in the morning, for example: You get up, take a shower, get dressed, eat breakfast. This simple daily routine solves a recurring problem through a series of well-defined steps. In computer science, such a routine is called an algorithm.

Erwig illustrates a series of concepts in computing with examples from daily life and familiar stories. Hansel and Gretel, for example, execute an algorithm to get home from the forest. The movie Groundhog Day illustrates the problem of unsolvability; Sherlock Holmes manipulates data structures when solving a crime; the magic in Harry Potter’s world is understood through types and abstraction; and Indiana Jones demonstrates the complexity of searching. Along the way, Erwig also discusses representations and different ways to organize data; “intractable” problems; language, syntax, and ambiguity; control structures, loops, and the halting problem; different forms of recursion; and rules for finding errors in algorithms.

This engaging book explains computation accessibly and shows its relevance to daily life. Something to think about next time we execute the algorithm of getting up in the morning.

About the Author

Martin Erwig is Professor of Computer Science in the School of Electrical Engineering and Computer Science at Oregon State University.


“...a thoughtful and approachable guide to the fundamentals of how computer science exists as an intellectual discipline.”—Times Higher Education


“This is a wonderful book. Algorithms and computation explained using the likes of Hansel and Gretel, Indiana Jones, Sherlock Holmes, and Harry Potter. For 35 years I've been trying to explain to people that algorithms are all around us, and that algorithmic thinking is an absolutely crucial skill that is needed in our day-to-day lives way beyond mere computers and electronics. Finally, here is a book for them to read.”
David Harel, Professor, The Weizmann Institute of Science, Vice President, Israel Academy of Sciences and Humanities; author of Algorithmics and Computers Ltd.: What they Really Can’t Do
“By connecting computing concepts with popular stories, Martin Erwig helps both the general public and students see computing’s relevance beyond traditional technology contexts. I suspect that readers will begin to see computing everywhere!”
Pat Yongpradit, Chief Academic Officer,
“Clever algorithms and data structures are at the core of computer science. This book is an excellent exposition of computational and informational thinking, and one that is unusually accessible to anyone with an inquiring mind.”
Simon Peyton Jones


2018 PROSE Award Honorable Mention, Computing and Information Science

Related Media

Hansel, Gretel, and Computer Science
Martin Erwig