0% found this document useful (0 votes)
269 views5 pages

Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!)

The document is a cheat sheet created by Eric Rowell that provides the time and space complexities of common algorithms and data structures. It includes tables summarizing the average, best, and worst case complexities of operations like search, insertion, and deletion for different data structures. Additional tables summarize the time and space complexities of common sorting algorithms. The cheat sheet aims to help engineers prepare for technical interviews by having the complexities readily available in one place.

Uploaded by

Nurlign Yitbarek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
269 views5 pages

Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!)

The document is a cheat sheet created by Eric Rowell that provides the time and space complexities of common algorithms and data structures. It includes tables summarizing the average, best, and worst case complexities of operations like search, insertion, and deletion for different data structures. Additional tables summarize the time and space complexities of common sorting algorithms. The cheat sheet aims to help engineers prepare for technical interviews by having the complexities readily available in one place.

Uploaded by

Nurlign Yitbarek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

5/10/2021 Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!

) @ericdrowell

Big-O Cheat Sheet Download PDF

Know Thy Complexities!


Hi there! This webpage covers the space and time Big-O complexities of common algorithms used in Computer
Science. When preparing for technical interviews in the past, I found myself spending hours crawling the internet
putting together the best, average, and worst case complexities for search and sorting algorithms so that I wouldn't
be stumped when asked about them. Over the last few years, I've interviewed at several Silicon Valley startups, and
also some bigger companies, like Google, Facebook, Yahoo, LinkedIn, and Uber, and each time that I prepared for
an interview, I thought to myself "Why hasn't someone created a nice Big-O cheat sheet?". So, to save all of you fine
folks a ton of time, I went ahead and created one. Enjoy! - Eric

Check out El Grapho, a graph data visualization library that supports millions
of nodes and edges

Big-O Complexity Chart


Horrible Bad Fair Good Excellent

O(n!) O(2^n)
O(n^2)

O(n log n)
Operations

O(n)

O(log n), O(1)

Elements

https://www.bigocheatsheet.com 1/5
5/10/2021 Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell

receptix
OPEN
Social Media Marketing Jobs

Common Data Structure Operations


Space
Data Structure Time Complexity
Complexity
Average Worst Worst
Access Search Insertion Deletion Access Search Insertion Deletion
Array Θ(1) Θ(n) Θ(n) Θ(n) O(1) O(n) O(n) O(n) O(n)

Stack Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Queue Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Singly-Linked List Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Doubly-Linked List Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Skip List Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n log(n))

Hash Table N/A Θ(1) Θ(1) Θ(1) N/A O(n) O(n) O(n) O(n)

Binary Search Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n)

Cartesian Tree N/A Θ(log(n)) Θ(log(n)) Θ(log(n)) N/A O(n) O(n) O(n) O(n)

B-Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)

Red-Black Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)

Splay Tree N/A Θ(log(n)) Θ(log(n)) Θ(log(n)) N/A O(log(n)) O(log(n)) O(log(n)) O(n)

AVL Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)

KD Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n)

Array Sorting Algorithms


Algorithm Time Complexity Space Complexity
Best Average Worst Worst
Quicksort Ω(n log(n)) Θ(n log(n)) O(n^2) O(log(n))

Mergesort Ω(n log(n)) Θ(n log(n)) O(n log(n)) O(n)

Timsort Ω(n) Θ(n log(n)) O(n log(n)) O(n)

Heapsort Ω(n log(n)) Θ(n log(n)) O(n log(n)) O(1)

Bubble Sort Ω(n) Θ(n^2) O(n^2) O(1)

Insertion Sort Ω(n) Θ(n^2) O(n^2) O(1)

Selection Sort Ω(n^2) Θ(n^2) O(n^2) O(1)

Tree Sort Ω(n log(n)) Θ(n log(n)) O(n^2) O(n)

Shell Sort Ω(n log(n)) Θ(n(log(n))^2) O(n(log(n))^2) O(1)

Bucket Sort Ω(n+k) Θ(n+k) O(n^2) O(n)

Radix Sort Ω(nk) Θ(nk) O(nk) O(n+k)

Counting Sort Ω(n+k) Θ(n+k) O(n+k) O(k)

Cubesort Ω(n) Θ(n log(n)) O(n log(n)) O(n)

Learn More
https://www.bigocheatsheet.com 2/5
5/10/2021 Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell

Cracking the Coding Interview: 150 Programming Questions and Solutions


Introduction to Algorithms, 3rd Edition
Data Structures and Algorithms in Java (2nd Edition)
High Performance JavaScript (Build Faster Web Application Interfaces)

Get the Official Big-O Cheat Sheet Poster

Contributors
Eric Rowell Quentin Pleple Michael Abed Nick Dizazzo Adam Forsyth Felix Zhu Jay Engineer
Josh Davis Nodir Turakulov Jennifer Hamon David Dorfman Bart Massey Ray Pereda Si Pham
Mike Davis mcverry Max Hoffmann Bahador Saket Damon Davison Alvin Wan Alan Briolat
Drew Hannay Andrew Rasmussen Dennis Tsang Vinnie Magro Adam Arold Alejandro Ramirez
Aneel Nazareth Rahul Chowdhury Jonathan McElroy steven41292 Brandon Amos Joel Friedly
Casper Van Gheluwe Eric Lefevre-Ardant Oleg Renfred Harper Piper Chester Miguel Amigot Apurva K
Matthew Daronco Yun-Cheng Lin Clay Tyler Orhan Can Ozalp Ayman Singh David Morton
Aurelien Ooms Sebastian Paaske Torholm Koushik Krishnan Drew Bailey Robert Burke

Make this Page Better


Edit these tables!

Find Latest social media marketing agency OPEN


Job Vacancies in Sydney on Receptix

https://www.bigocheatsheet.com 3/5
5/10/2021 Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell

Sponsored

Do You Speak English? Work a USA job from home in Ethiopia


Work from home | Search Ads

Modular Kitchen Costs Might Actually Surprise You


Modular Kitchen | Search Ads

Photos Show The Difference Between Meghan & Kate


Dailyforest

The Kate Upton Transformation


TravelerMaster

Jennifer Lopez No Makeup Photo Confirms The Rumors


Car Novels

Susan Boyle Is Almost 60, Try Not To Smile When You See Her
Now
Half Eddie

505 Comments Big-O Cheat Sheet 🔒 


1 Login

 Recommend 337 t Tweet f Share Sort by Best

Join the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS ?

Name

Michael Mitchell • 8 years ago


This is great. Maybe you could include some resources (links to
khan academy, mooc etc) that would explain each of these
concepts for people trying to learn them.
382 △ ▽ 1 • Reply • Share ›

Amanda Harlin > Michael Mitchell • 8 years ago


Yes! Please & thank you
83 △ ▽ • Reply • Share ›

https://www.bigocheatsheet.com 4/5
5/10/2021 Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell

Sponsored

Do You Speak English? Work a USA job from home in Ethiopia


Work from home | Search Ads

Recognize Her? Paris Jackson Through The Years


BeautifulTrendsToday

https://www.bigocheatsheet.com 5/5

You might also like