A Beginner’s Guide to Big O Notation (Part 2)

An introduction to time complexity with help from Ratatouille

Alison Quaglia
The Startup

--

Well hey there, Chef Remy! Welcome back to the kitchen!

chef remy from ratatouille
Image credit: Pixar

Today we’re going to complete our intro to Big O Notation with O(log n), O(n log n), O(2^n) and O(n!) via an impeccable film, Pixar’s Ratatouille. When we last left off, we were preparing our famous ratatouille dish for notorious restaurant critic Anton Ego who was waiting patiently for his meal.

As a refresher, check out the time complexity comparison chart below:

big o notation complexity comparison chart

O(log n) Log Time

Let’s say our waiter received an order from a mysteriously cloaked man (Chef Skinner in disguise! 🕵🏻‍♂️) who said “I’ll have what he’s having” in reference to Anton Ego.

chef skinner ratatouille gif

We know that Anton Ego is seated at table 29, so we will need to look up his food order through his table number. Lucky for us, the table numbers are always kept sorted in our array of orders

--

--

Alison Quaglia
The Startup

Software Engineer @ Pinterest. Bridging the gap between development and design. A believer in kindness above all things. 🌱