• Post Reply Bookmark Topic Watch Topic
  • New Topic

Load factor for a map  RSS feed

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know on the exact load factor that should be used in a map in the scenario when there is a lot of insertion/deletion happens. I guess the load factor should be chosen close to 1 and my assumption is that capacity will only be increased only when this load factor reaches. however I need expert opinion on this.
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a trade-off between memory use and speed. You probably shouldn't go higher than 0.9, and even 0.5 might be fine (unless we're talking about a map containing millions of entries, in which case you should do some load testing and observe the resulting speed).

Wirth's classic book Algorithms and Data Structures does some analysis on hashing key collisions in chapter 5.4; it's short and well worth a read.
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a "beginning" topic. Moving thread.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!