What is the time complexity of Java hashCode method for the String class? -


is java's hashcode method string class computed in constant time or linear time? algorithm used?

the documentation tells function:

s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]

it's computed once using linear-time pass, , cached it's o(1) retrieve in future.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -