0

MSDN says:

When an element is added to the Hashtable, the element is placed into a bucket based on the hash code of the key.

But I cannot find any information how are buckets organized or created. How are buckets ordered(alphabetically)? What basic principle to create a bucket in a hashtable?

I mean for example, a word "Tom" has a hashcode which is 3. Well, a word "TomTom" has another hashcode, for example, which is 6. My question is in which buckets will these words be putted and why?

StepUp
  • 36,391
  • 15
  • 88
  • 148
  • possible duplicate of [How does a hash table work?](http://stackoverflow.com/questions/730620/how-does-a-hash-table-work) – TomTom Apr 02 '14 at 06:02
  • @TomTom have you read this article? There is a some supposition of buckets. However, it is just a supposition. – StepUp Apr 02 '14 at 06:18

1 Answers1

4

How can you not find that basic information? Even Wikipedia has a good explanation? I mean, seriously. This is basic data structures 102 - there are tons of books about it. There are sites about it. Wikipedia describes ton of methods to do that. How the .NET framework does it is not important (implementation detail) as it may change between versions, and even then - the source code is public, so "no information" is wrong again.

For example here you can find the official source code for a 3.5 version.

nawfal
  • 70,104
  • 56
  • 326
  • 368
TomTom
  • 61,059
  • 10
  • 88
  • 148
  • yeah, I've read this articles but I cannot understand what a bucket is. Is this a spot for one item or we can put many items in the bucket? – StepUp Apr 02 '14 at 02:51
  • So now we are back to you now knowing basic data structures and enough programming to understnd them. Voting to close as now it beecomes clear this is a duplicate of http://stackoverflow.com/questions/730620/how-does-a-hash-table-work ;) – TomTom Apr 02 '14 at 06:01
  • this topic is about how are buckets created not how does hashtable work:). – StepUp Apr 02 '14 at 06:22
  • That is in the code. Look, the explanations in wikipedia, the reference an the code are all you need. If you have a problem with thise, a beginner C# or a fundamental programming book are more appropirate - or maybe the understanding that you just aren ot cut as a programmer because if this is making your problems, things get a LOT worse later. – TomTom Apr 02 '14 at 06:28
  • I mean for example, a word "Tom" has a hashcode which is 3. Well, a word "TomTom" has another hashcode, for example, which is 6. My question is in which buckets will these words be putted and why? – StepUp Apr 02 '14 at 07:10