Searching
Algorithm |
Data Structure |
Time Complexity |
Space Complexity |
|
Average |
Worst |
Worst |
||
Graph
of |V| vertices and |E| edges |
- |
O(|E|
+ |V|) |
O(|V|) |
|
Graph
of |V| vertices and |E| edges |
- |
O(|E|
+ |V|) |
O(|V|) |
|
Sorted
array of n elements |
O(log(n)) |
O(log(n)) |
O(1) |
|
Array |
O(n) |
O(n) |
O(1) |
|
Shortest path by Dijkstra, |
Graph
with |V| vertices and |E| edges |
O((|V|
+ |E|) log |V|) |
O((|V|
+ |E|) log |V|) |
O(|V|) |
Shortest path by Dijkstra, |
Graph
with |V| vertices and |E| edges |
O(|V|^2) |
O(|V|^2) |
O(|V|) |
Graph
with |V| vertices and |E| edges |
O(|V||E|) |
O(|V||E|) |
O(|V|) |
Sorting
Algorithm |
Data Structure |
Time Complexity |
Worst Case Auxiliary Space Complexity |
||
Best |
Average |
Worst |
Worst |
||
Array |
O(n
log(n)) |
O(n
log(n)) |
O(n^2) |
O(n) |
|
Array |
O(n
log(n)) |
O(n
log(n)) |
O(n
log(n)) |
O(n) |
|
Array |
O(n
log(n)) |
O(n
log(n)) |
O(n
log(n)) |
O(1) |
|
Array |
O(n) |
O(n^2) |
O(n^2) |
O(1) |
|
Array |
O(n) |
O(n^2) |
O(n^2) |
O(1) |
|
Array |
O(n^2) |
O(n^2) |
O(n^2) |
O(1) |
|
Array |
O(n+k) |
O(n+k) |
O(n^2) |
O(nk) |
|
Array |
O(nk) |
O(nk) |
O(nk) |
O(n+k) |
Heaps
Heaps |
Heapify |
Find Max |
Extract Max |
Increase Key |
Insert |
Delete |
Merge |
- |
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(log(n)) |
O(log(n)) |
O(log(n)) |
O(log(n)) |
O(log(n)) |
O(log(n)) |
|
- |
O(1) |
O(log(n))* |
O(1)* |
O(1) |
O(log(n))* |
O(1) |
Graphs
Node
/ Edge Management |
Storage |
Add
Vertex |
Add
Edge |
Remove
Vertex |
Remove
Edge |
Query |
O(|V|+|E|) |
O(1) |
O(1) |
O(|V|
+ |E|) |
O(|E|) |
O(|V|) |
|
O(|V|+|E|) |
O(1) |
O(1) |
O(|E|) |
O(|E|) |
O(|E|) |
|
O(|V|^2) |
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(|V|
⋅ |E|) |
O(|E|) |
Data Structures
Data Structure |
Time Complexity |
Space Complexity |
|||||||
Average |
Worst |
Worst |
|||||||
Indexing |
Search |
Insertion |
Deletion |
Indexing |
Search |
Insertion |
Deletion |
||
O(1) |
O(n) |
- |
- |
O(1) |
O(n) |
- |
- |
O(n) |
|
O(1) |
O(n) |
O(n) |
O(n) |
O(1) |
O(n) |
O(n) |
O(n) |
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) |
Notation for asymptotic growth
letter |
bound |
growth |
(theta)
Θ |
upper
and lower, tight[1] |
equal[2] |
(big-oh)
O |
upper,
tightness unknown |
less
than or equal[3] |
(small-oh)
o |
upper,
not tight |
less
than |
(big
omega) Ω |
lower,
tightness unknown |
greater
than or equal |
(small
omega) ω |
lower,
not tight |
greater
than |
No comments:
Post a Comment
Open Researcher and Contributor ID (ORCID)