0% found this document useful (0 votes)
265 views2 pages

Big O Cheatsheet

The document is a cheat sheet that provides the time and space complexities of common data structures and algorithms. It includes the complexities for operations like access, search, insertion, and deletion on data structures like arrays, linked lists, stacks, queues, trees, and graphs. It also includes the time complexities of common sorting algorithms and heap operations. The cheat sheet acts as a quick reference for comparing the performance of different data structures and algorithms.

Uploaded by

Karishma
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)
265 views2 pages

Big O Cheatsheet

The document is a cheat sheet that provides the time and space complexities of common data structures and algorithms. It includes the complexities for operations like access, search, insertion, and deletion on data structures like arrays, linked lists, stacks, queues, trees, and graphs. It also includes the time complexities of common sorting algorithms and heap operations. The cheat sheet acts as a quick reference for comparing the performance of different data structures and algorithms.

Uploaded by

Karishma
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/ 2

Know Thy Complexities!

www.bigocheatsheet.com

Legend
Excellent

Good

Fair

Bad

Horrible

Data Structure Operations


Data Structure

Space
Complexity
Worst

Time Complexity
Average
Access

Search

Insertion

Deletion

Worst
Access

Search

Insertion

Deletion

Array

O(1)

O(n)

O(n)

O(n)

O(1)

O(n)

O(n)

O(n)

O(n)

Stack
Singly-Linked List
Doubly-Linked List
Skip List
Hash Table
Binary Search Tree
Cartesian Tree
B-Tree
Red-Black Tree
Splay Tree
AVL Tree

O(n)

O(n)

O(1)

O(1)

O(n)

O(n)

O(1)

O(1)

O(n)

O(n)

O(n)

O(1)

O(1)

O(n)

O(n)

O(1)

O(1)

O(n)

O(n)

O(n)

O(1)

O(1)

O(n)

O(n)

O(1)

O(1)

O(n)

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(n)

O(n)

O(n)

O(n)

O(n log(n))

O(1)

O(1)

O(1)

O(n)

O(n)

O(n)

O(n)

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(n)

O(n)

O(n)

O(n)

O(n)

O(log(n))

O(log(n))

O(log(n))

O(n)

O(n)

O(n)

O(n)

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(n)

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(n)

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(n)

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(n)

Array Sorting Algorithms


Algorithm
Quicksort
Mergesort
Timsort
Heapsort
Bubble Sort
Insertion Sort
Selection Sort
Shell Sort
Bucket Sort
Radix Sort

Time Complexity
Best
Average

Worst

Space Complexity
Worst

O(n log(n))

O(n log(n))

O(n^2)

O(log(n))

O(n log(n))

O(n log(n))

O(n log(n))

O(n)

O(n)

O(n log(n))

O(n log(n))

O(n)

O(n log(n))

O(n log(n))

O(n log(n))

O(1)

O(n)

O(n^2)

O(n^2)

O(1)

O(n)

O(n^2)

O(n^2)

O(1)

O(n^2)

O(n^2)

O(n^2)

O(1)

O(n)

O((nlog(n))^2)

O((nlog(n))^2)

O(1)

O(n+k)

O(n+k)

O(n^2)

O(n)

O(nk)

O(nk)

O(nk)

O(n+k)

Graph Operations
Node / Edge Management Storage
O(|V|+|E|)
Adjacency list
O(|V|+|E|)
Incidence list
O(|V|^2)
Adjacency matrix
O(|V| |E|)
Incidence matrix

Add Vertex

Add Edge

Remove Vertex Remove Edge Query

O(1)

O(1)

O(|V| + |E|)

O(|E|)

O(|V|)

O(1)

O(1)

O(|E|)

O(|E|)

O(|E|)

O(|V|^2)

O(1)

O(|V|^2)

O(1)

O(1)

O(|V| |E|)

O(|V| |E|)

O(|V| |E|)

O(|V| |E|)

O(|E|)

Heap Operations
Type

Time Complexity
Heapify
Find Max

Extract Max

Increase Key Insert

Delete

Merge

Linked List (sorted)


Linked List (unsorted)
Binary Heap
Binomial Heap
Fibonacci Heap

O(1)

O(1)

O(n)

O(n)

O(1)

O(m+n)

O(n)

O(n)

O(1)

O(1)

O(1)

O(1)

O(n)

O(1)

O(log(n))

O(log(n))

O(log(n))

O(log(n))

O(m+n)

O(1)

O(log(n))

O(log(n))

O(1)

O(log(n))

O(log(n))

O(1)

O(log(n))

O(1)

O(1)

O(log(n))

O(1)

Big-O Complexity Chart

You might also like