Explained step by step
To estimate complexity you count operations, but with 3 shortcuts. Fixed terms are ignored, like "3 operations before the loop", because they don't depend on n. Numbers multiplying n are ignored: a loop of 2n or 5n + 1 rounds counts as n. And in nested loops you multiply each loop's rounds. It's like estimating how long reading a book takes: what matters is how many pages it has, not that you spent 2 minutes looking for your glasses first.
An algorithm being O(1) doesn't mean it's fast, but that its work doesn't depend on n. Code that repeats something 1 million times, whether n is 10 or 10 million, is O(1): it takes long, but always the same. That's a limit of complexity: 2 O(1) algorithms can take 1 step or 1 million, and an O(n) one can beat an O(1) one when n is small. It describes how it grows, not how long it takes.
When n gets huge, the fastest-growing term swallows the others. In 2n² + 3n + 2, with n = 1,000, n² gives 2 million and 3n barely 3,000: the rest hardly changes the total. That's why complexity keeps the highest-degree term. Not even a giant multiplying number is enough: 10,000n² is still O(n²), and n³ beats it anyway once n is large enough.
O(n log n) shows up when you do n operations on each of log n levels. For example, when you split a list in half over and over there are about log₂ n levels, and at each level all n elements are touched. With 1 million items that's about 20 levels × 1 million = 20 million steps. It's the complexity of good sorting algorithms: quicksort, merge sort and heap sort.
In O(2ⁿ), the work doubles every time n goes up by 1. It's like a cell dividing: 1, 2, 4, 8... after 10 rounds there are 1,024; after 30, over 1 billion. It shows up in recursions that branch into 2 at each step and in searches that try every combination. With large n it's unusable, which is why those problems are tackled with dynamic programming or greedy algorithms.
O(n!) shows up when trying every possible order of n elements. For the first spot there are n options, for the second n − 1, and so on: n! = n × (n − 1) × ... × 1. With 3 elements it's 6 orders; with 10, over 3.6 million; with 20, over 2 quintillion. It grows even faster than 2ⁿ: from n = 4 on, n! is always bigger. It's like listing every way to seat the guests at a table.
An algorithm's speed can depend on how the data comes in. If you look for the 1 in a shuffled list of n numbers, the best case is that it's first: 1 step. The worst case is that it's last: n steps. The average case, if it can be anywhere, is n/2 steps. The worst case is almost always used, because it's a guarantee: it'll never be slower than that. The best case is unlikely and gives a misleading idea.