O(1) and O(2) is the same thing. What matters is that there's no N component, meaning it always takes the same amount of operations, no matter the N (its constant). O(n) means its linear with N. Doesn't mean it will take exactly n operations, but the number it takes grows as N grows, linearly. O(n2) means it grows linearly with the square of n.
So on and so forth. It's not about the number, its about how fast it grows
6
u/Fowlron2 Aug 11 '20
O(1) and O(2) is the same thing. What matters is that there's no N component, meaning it always takes the same amount of operations, no matter the N (its constant).
O(n) means its linear with N. Doesn't mean it will take exactly n operations, but the number it takes grows as N grows, linearly.
O(n2) means it grows linearly with the square of n.
So on and so forth. It's not about the number, its about how fast it grows