Major Algorithms Flashcards
Depth First Search, DFS (Time)
Worst is O(|E| + |V|) for Edges and Vertices
Depth First Search, DFS (Space)
Worst is O(|V|) for Vertices
Breadth First Search, BFS (Time)
Worst is O(|E| + |V|) for Edges and Vertices
Breadth First Search, BFS (Space)
Worst is O(|V|) for Vertices
Binary Search (sorted array of n elements) (Time)
Average is O(log(n)) and worst is the same
Binary Search (Space)
Worst is O(1)
Linear (Brute Force) search of an array (Time)
Average and Worst are both O(n)
Linear (Brute Force) search of an array (Space)
O(1)
Shortest path by Dijkstra,
using a Min-heap as priority queue (Time)
Average and Worst are both O((|V| + |E|) log|V|) for Vertices and Edges
Shortest path by Dijkstra,
using a Min-heap as priority queue (Space)
Worst case is O(|V|) for Vertices
Shortest path by Dijkstra,
using an unsorted array as priority queue (Time)
Average and Worst are both O(|V|^ 2) for the Vertices
Shortest path by Dijkstra,
using an unsorted array as priority queue (Space)
Worst is O(|V|) for the Vertices
Shortest path by Bellman-Ford (Time)
Average and Worst are both O(|V| |E|)
Shortest path by Bellman-Ford (Space)
Worst is O(|V|)
Quicksort(Time)
Best and average are O(n log n) Worst is O(n^2)