Jieyi Wu
Jieyi Wu
Aug 23, 2017 · 1 min read

I’m sorry that I didn’t explain clearly.

If we don’t set the the capacity for a new HashMap, the default is 16 .

Assume we put 1600 entities to HashMap and HashMap make all entities average to each of them.

Entry 0   --> Entry   --> Entry   ...   --> Entry
Entry 1 --> Entry --> Entry ... --> Entry
Entry 2 --> Entry --> Entry ... --> Entry
Entry 3 --> Entry --> Entry ... --> Entry
Entry 4 --> Entry --> Entry ... --> Entry
.
.
.
Entry 14 --> Entry --> Entry ... --> Entry
Entry 15 --> Entry --> Entry ... --> Entry

This is average case, but the worst case will be as below

Entry 0   --> Entry   --> Entry   ...   --> Entry
Entry 1
Entry 2
Entry 3
Entry 4
.
.
.
Entry 14
Entry 15

So I talk about the worst case will be O(n).

)
    Jieyi Wu

    Written by

    Jieyi Wu

    Making the impossible possible. github(https://github.com/pokk) gitbook(https://www.gitbook.com/@pokk)

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade