Comment by thaumasiotes

4 years ago

This is O(1) where N is constant.

Yes. Everything is O(1) if N is constant, including log(N), N^2, 2^N, N!, etc. That's a tautology.

  • > Everything is O(1) if N is constant, including log(N), N^2, 2^N, N!, etc.

    Not even close. 2^k is not O(1) by virtue of N being constant. Only 2^N.

    This has been covered above. It is more common to consider the complexity of hash table operations in terms of the number of operations, or the size of the table; the size of the key is very often constant. These are different variables; the constant size of the key does not trivialize the complexity of inserting N items each with a constant key size.