Big O
This is the nicest intro and should clear things up.
| Big-O Complexity | Name / Growth Rate | Typical Examples |
|---|---|---|
| Constant | Array indexing, hash table lookup, pushing/popping from a stack or queue | |
| Logarithmic | Binary search, tree search in balanced BST/AVL/Red-Black Tree, heap operations (insert/extract-min) | |
| Linear | Linear search, traversing an array or linked list, finding max/min in unsorted list | |
| Log-linear | Merge sort, heap sort, quicksort (average case), efficient sorting in general | |
| Quadratic | Bubble sort, insertion sort, selection sort, checking all pairs in a list | |
| Cubic | Naïve matrix multiplication, checking all triplets | |
| Exponential | Recursive solution to Traveling Salesman Problem (TSP), generating all subsets, naïve Fibonacci recursion | |
| Factorial | Solving Traveling Salesman by brute force, generating all permutations |
Operations on most Python data structures (e.g. appending a list, checking membership in a tuple) are , , or .
Also note that if you do things times, your complexity is