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

Правка en3, от 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??

Теги #java8, #hashing, #optimization

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Aabhas99 2021-04-19 07:42:04 2 Tiny change: 'ot intialise it then ' -> 'ot intialize it then '
en2 Английский Aabhas99 2020-10-28 21:18:50 1 Tiny change: 'solution???' -> 'solution??'
en1 Английский Aabhas99 2020-10-28 09:30:43 389 Initial revision (published)