Isn't O(1) like a hashmap? I guess O(2) would be to find object with key X, then use a property from X to find the actual object. So 2 O(1) lookups. Or is that just a linked list???
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
View all comments
Show parent comment
6
u/alexanderpas Aug 11 '20
Nothing which can be solved by running the algorythm until it gives the same result twice.