Complexities Table
来源:互联网 发布:淘宝免费模块代码 编辑:程序博客网 时间:2024/04/30 08:30
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 eBay, 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
If you're trying to catch them all, you might also check out the Pokemon Go Evolution Chart.
Big-O Complexity Chart
Horrible
Bad
Fair
Good
Excellent
Common Data Structure Operations
Θ(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 TableN/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 TreeN/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 TreeN/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
Ω(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
- 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!- Complexities Table
- Complexities
- Know Thy Complexities!
- Know Thy Complexities!
- The Complexities of Concurrency
- Know Thy Complexities! (各种算法的复杂度)
- TABLE
- table
- table
- table
- Table
- table
- TABLE
- table
- Table
- table
- Table
- table
- CUDA 学习(二十二)、优化策略7: 自调优应用程序
- SSH的优势和劣势
- Python语言编写BP神经网络
- mysql错误
- CocoaPods pod install的时候报错:invalid byte sequence in UTF-8 (ArgumentError)解决办法
- Complexities Table
- nodejs pm2教程
- input file控件美化
- Selenium学习16--ExcelUtil
- 深入理解Linux修改hostname
- HALCON学习-下载、安装
- JavaScript BOM和DOM操作教程
- logstash kafka多台机器取数据,只有一个实例消费【logstash2.3.4】
- Android项目重构之路:实现篇