What is the complexity for BST
Best case search O(1)
Worst case (LL) O(n)
Average case O(logn)
Max heap height?
O(log n)
Heap Creation.
Bottom Up
Top Down
O(n) worst case
O(nlogn) worst case
Adjacency List
Adjacency Matrix
O(|V| + |E|)
O(|V|^2)
Topological Sort
O(|V|+|E|)
Dijkstra’s Algorithm
O(|V|^2)
heap: O((|E|+|V|)+log|V|)
shortest path between all pairs O(|V|^3)
Kruskal’s Algorithm
number of edges = |V| - 1
O(|E|log|V|)
Prim’s Algorithm
Simple algorithm: O(|V|^2)
Heap: O(|E|log|V|)
Hashing Function
O(1)
Separate chaining
Accessing/Finding List O(1)
Finding a key O(n)