Is it optimal to initialise hashmaps in java(8+) with some big value?

Revision en3, by Aabhas99, 2021-04-19 07:42:04

If we know the number of entries beforehand, lets say v, then is it optimal to initialise the hashmap in java with size v or v/load_factor???

If we donot intialize it then it will be of size 16 and many times rehashing would be done.

So, on an average in contests what size should be chosen for optimal solution??

Tags #java8, #hashing, #optimization

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Aabhas99 2021-04-19 07:42:04 2 Tiny change: 'ot intialise it then ' -> 'ot intialize it then '
en2 English Aabhas99 2020-10-28 21:18:50 1 Tiny change: 'solution???' -> 'solution??'
en1 English Aabhas99 2020-10-28 09:30:43 389 Initial revision (published)