Time Complexity

Binary Search
0(1)
O(Log(N))
Linear Search
0(1)
O(N)
BFS
O(V + E)
O(V + E)
DFS
O(V + E)
O(V + E)
Dijkstra's Algorithm
O(V^2)
Bubble Sort
O(N)
O(N^2)
Selection Sort
O(N^2)
O(N^2)
Insertion Sort
O(N)
O(N^2)
Quick Sort
O(N * Log(N))
O(N^2)
Merge Sort
O(N * Log(N))
O(N * Log(N))
Counting Sort
O(N+K)
O(N+K)
Array - (Search - Insert - Delete)
O(N)
O(N)
Linked List = (Search)
O(N)
O(N)
Linked List = (Insert - Delete)
0(1)
O(N)
Map (use BST)
O(Log(N))
Unordered Map (use HashMap)
0(1)
Stack + Queue
= (Search)
O(N)
O(N)
Stack + Queue
= (Insert - Delete)
0(1)
0(1)
HashMap - (Search - Insert - Delete)
0(1)
O(N)
Binary Search Tree (BST) - (Search - Insert - Delete)
O(Log(N))
O(N)
Binary Tree - (Search - Insert - Delete)
O(Log(N))
O(N)
Prime Number : The time complexity of this code is 𝑂 ( Root(N))
Last updated