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 ... --> EntryThis 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).
