Big-O Cheat Sheet Sorting, Searching and Data Structures Algorithms, Cheat Sheet of Data Structures and Algorithms

Big O indicates the complexity level of an algorithm in best, average and worst cases. Big O cheat sheet lists complexity of famous and widely used algorithms

Typology: Cheat Sheet

2020/2021

Uploaded on 04/27/2021

eekbal
eekbal 🇺🇸

4.6

(30)

263 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Big-O Cheat Sheet
Generated December 2013.
B. Amos
1 Searching
Algorithm Data Structure Time Complexity Space Complexity
Average Worst
Depth First Search (DFS) Graph of |V|vertices and
|E|edges
-O(|E|+|V|)O(|V|)
Breadth First Search
(BFS) Graph of |V|vertices and
|E|edges
-O(|E|+|V|)O(|V|)
Binary search Sorted array of n elements O(log(n)) O(log(n)) O(1)
Linear (Brute Force) Array O(n)O(n)O(1)
Shortest path by Dijkstra,
using a Min-heap as prior-
ity queue
Graph with |V|vertices
and |E|edges
O((|V|+|E|) log |V|)O((|V|+|E|) log |V|)O(|V|)
Shortest path by Dijkstra,
using an unsorted array as
priority queue
Graph with |V|vertices
and |E|edges
O|V|2O|V|2O(|V|)
Shortest path by Bellman-
Ford Graph with |V|vertices
and |E|edges
O(|V||E|)O(|V||E|)O(|V|)
1
pf2