Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

La Vivien Post

Software Engineering and Beyond

Skip to content

La Vivien Post Home


Tech Visuals
Source Code
Store
Contact Us

Home Technology Landscape Big O notation cheat sheet – leetcode cheat sheet

YouTube
Big O notation cheat sheet – leetcode Pinterest
cheat sheet Github

La Vivien March 15, 2024 June 7, 2024


Search for: Search

Search
Big O notation cheat sheet provides the Big O notations for data structures and algorithm, including
arrays, linked list, trees, hash tables, graphs, sorting, search, recursion, DFS and BFS, and memoization,
Recent Posts
Dynamic programming etc. It also includes leetcode Big O cheat sheet for common interview questions.
The links are provided to download the jpg file of the cheat sheets. At the end, you can also get the link Use ControlNet in Stable
to download the Big O notation cheat sheet compilation in a poster. Diffusion Webui
Autocomplete with trie (3
What is the Big O notation cheat sheet?
solutions) – Code
Big O notation cheat sheet summarizes commonly used Big O notations (time complexity and space Depth first search in matrix
complexity) in software programming. using recursion
Install TensorFlow GPU on
What is a leetcode cheat sheet?
Windows – A complete guide

The leetcode big O cheat sheet summarizes the Big O notations (time complexity and space complexity)
Categories
for the leetcode interview questions in data structures and algorithms.
Digital Products
Table of Content Source Code
Tech Journey
Big O Notation of Data Structures Technology Landscape
Big O Notation of leetcode Algorithms
Big O Notation of Sorting Algorithms La Vivien’s Illustrated Data
structures (Java) book
Big O Notation of leetcode questions in Recursions
Big O Notation of leetcode questions in DFS and BFS
Big O Notation of Java Collections
For your consideration

Big O notation – Data Structures

Grokking Data Structures


Data structure Access Insert Delete Search Traverse

Linear
Array O(1) O(1) O(n) O(n) O(n)

Ordered array O(1) O(n) O(n) O(logn) O(n)

Linked list O(n) O(1) O(n) O(n) O(n)

Matrix O(1) O(1) O(1) O(m*n) O(m*n)

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

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

Non-linear

Tree O(n) O(1) O(n) O(n) O(n)


Big O Notation Cheat sheet
Balanced tree O(logn) O(logn) O(logn) O(logn) O(n)

Graph O(V) O(1) O(V+E) O(V+E) O(V+E)

Trie O(s) O(s) O(s) O(s) O(n*s)

Suffix trie O(s) O(s) O(s) O(s) O(s^2)


Download data structure cheat sheet

Big O notation cheat sheet – leetcode algorithms

Algorithms Time Space Used area Java coding interview


Sorting
book

Bubble, Selection, Insertion O(n^2) O(1) Simple sort

Merge sort O(n*logn) O(n) Stable sort

Quick sort O(n*logn) O(logn) Quick sort

Searching

Linear search O(n) O(1) Search in non-sorted array

Binary search O(logn) O(1) Search in sorted array

Recursion

Factorial O(n) O(n) Math

Valid parentheses O(Cn) O(Cn) String Data structures Python


book
Permutation O(n!) O(n!) Array, String

All subsets O(2^n) O(2^n) Array, String

Dynamic Programming

Fibonacci O(n) O(1) Math

Knapsack O(n*w) O(n*w) Array

Edit distance O(s*t) O(t) String

Num of unique paths in matrix O(m*n) O(n) Matrix


Download algorithms cheat sheet

Big O notation – Sorting Algorithms

Sort Best Avg Worst Space Stable

Bubble sort O(n) O(n^2) O(n^2) O(1) Yes

Selection sort O(n^2) O(n^2) O(n^2) O(1) No

Insertion sort O(n) O(n^2) O(n^2) O(1) Yes Data structures JavaScript
book
Merge sort O(n*logn) O(n*logn) O(n*logn) O(n) Yes

Quick sort O(n*logn) O(n*logn) O(n^2) O(logn) No


Download sorting cheat sheet

Big O notation cheat sheet – leetcode Recursions

Combinatorics Sample questions Formulas Time

Permutations Permutation of array P(n, k) = n!/(n-k)! O(P(n,k)), O(n!) when k=n

Combinations Combination of range 1..n size k C(n, k) = n!/(n-k)!k! O(C(n,k))

Combinations of
Combination of subset strings C(m, n) = m^n O(m^n)
subset

All subsets All subset of array C(2, n)= 2^n O(2^n)

Catalan numbers Generate valid parentheses Cn = (2n)!/(n+1)!n! O(Cn)


Download recursions cheat sheet

Big O notation cheat sheet – leetcode DFS and BFS

DFS and BFS use cases Sample questions Time

DFS in tree Tree in-order traversal O(n)

DFS in string without memo Word break with recursion O(2s)

DFS in string with memo Word break with rec and memo O(s2)

DFS in graph with memo Graph DFS traversal O(V+E)

DFS in matrix with memo Number of island O(m*n)

BFS in tree Tree level order traversal O(n)

BFS/Bi-directional BFS Word ladder with memo O(s*n)


in string with memo

BFS in graph with memo Graph BFS traversal O(V+E)

Find path with BFS in graph Find path from src to dest O(bd)

Find path with Bi-directional BFS


Find path with bi-directional BFS O(bd/2)
in graph

Shortest path with BFS in


Shortest path from src to dest O(V+E)
unweighted and undirected graph

Shortest path with BFS


Shortest path between cells O(m*n)
in adjacent matrix
Download DFS and BFS cheat sheet

Big O notation – Java Collections

Java Collections APIs Access Insert Delete Search Traverse

List

ArrayList O(1) O(1) O(n) O(n) O(n)

LinkedList O(n) O(1) O(n) O(n) O(n)

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

Queue

ArrayDeque O(1) O(1) O(1) O(n) O(n)

PriorityQueue O(logn) O(logn) O(logn) O(logn) O(n)

Map

HashMap O(1) O(1) O(1) O(1) O(n)

LinkedHashMap O(1) O(1) O(1) O(1) O(n)

TreeMap O(logn) O(logn) O(logn) O(logn) O(n)

Dictionary

Hashtable O(1) O(1) O(1) O(1) O(n)

Set

HashSet O(1) O(1) O(1) O(1) O(n)

LinkedHashSet O(1) O(1) O(1) O(1) O(n)

TreeSet O(logn) O(logn) O(logn) O(logn) O(n)


Download Java collections cheat sheet

For your consideration


Big O Notation Cheat Sheet Poster Big O Notation mug
Big O Notation Cheat Sheet Poster Big O Notation mug at Etsy
$4.8 Ask me for a free coffee mug

Share this:
Click to share on Twitter (Opens in new window)
Click to share on Facebook (Opens in new window)
Click to share on LinkedIn (Opens in new window)
Click to share on Pinterest (Opens in new window)

Related
Quick Links
Home Page
Java Coding Questions and PDF
Data Structures Illustrations and PDF
Grokking Data Structures PDF
Contact Us

Newsletter

E-mail

Submit

©La Vivien Post, All rights reserved.


Disclosure policy Privacy policy Terms

You might also like