C is the only wrong one. It has no consistent output.
That's the correct answer.
10 points to @OliverA!
0.625 points to @Star-Dust!
I'll try to explain and I recommend you all to download the HashTable example. The code is simple and you will understand how Map works. Map is the number #1 collection
The Map collection is made of buckets. The pairs of keys and values are stored in these buckets.
Lets say that there are 10 buckets and the code is:
Map.Put("Red", 0xffff0000)
Map.Put("Green", 0xff00ff00)
Map.Put("Blue", 0xff0000ff)
Log(Map.Get("Green"))
We want to get the value that is tied to the key "Green".
We need to find the bucket that stores this key.
First step is to calculate the hash number of "Green". Maybe 234908908.
The bucket number is found with:
Dim BucketIndex As Int = Hash Mod NumberOfBuckets '234908908 Mod 10 = 8
In this case it will be 8.
So we go to bucket #8 and now we need to go over all the items in this bucket and compare the given key with their key:
Dim Bucket8Items As List = Bucket8.Items
For Each kv As KeyAndValue In Bucket8Items
If kv.Key = "Green" Then Return kv.Value
Next
Return "Not found"
Previously when we added "Green" to the Map the hash code was the same so it was stored in bucket #8.
Any consistent hash will work. For example if the hash function will always return 0 then all items will be stored in bucket #0. The downside of such hash function is that we will need to compare the key with all other keys each time. It will be slow and act like a List (O(n) complexity).
A good hash function is supposed to be consistent and to more or less have a uniform distribution. This way the number of items in each bucket will be minimal and putting or getting items from the buckets will be quick.