Skip to main content

Command Palette

Search for a command to run...

πŸ“ Big O Explained Like You're 5

Published
β€’2 min read
S

Building AI systems and writing about how they actually work. Master of AI @ University of Technology Sydney. Previously B.Tech CS with focus on IoT. I believe the best way to learn is to explain. That's why I'm documenting tech concepts with simple analogies (@sreekarreddy.com). AWS Certified β€’ Azure AI Certified β€’ Neo4j Professional β€’ Google Data Analytics When not coding: exploring Sydney, working on side projects, and teaching tech to anyone who'll listen.

Worst-case traffic time estimate

Day 40 of 149

πŸ‘‰ Full deep-dive with code examples


The Traffic Estimate

Your friend asks: "How long does your commute take?"

You could say:

  • "A short commute" (light traffic)
  • "A long commute" (worst case: traffic)

Big O is like worst-case estimate for algorithms!


Common Big O's

Big OMeaningExample
O(1)ConstantGet item by index
O(log n)LogarithmicBinary search
O(n)LinearLoop through all
O(nΒ²)QuadraticNested loops

What They Mean

O(1): Same time no matter the size

  • Get arr[5] with 10 items = Get arr[5] with 1 million items

O(n): Time grows with size

  • 10 items β†’ check 10
  • 1000 items β†’ check 1000

O(nΒ²): Time grows FAST

  • 10 items β†’ 100 operations
  • 1000 items β†’ 1,000,000 operations 😱

Visual

     |     O(nΒ²)
Time |   /
| O(n)     |
| ___ O(1) |
     +---------β†’
        Size

In One Sentence

Big O describes how an algorithm's time grows as input size grows, focusing on worst-case scenarios.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

More from this blog

esreekarreddy

132 posts