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

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

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -