A Hashtable implements the IDictionary interface and as such it is a data structure that supports key-and-value pair look ups. The Hashtable is defined by two variables: The load factor and the initial capacity. The initial capacity is the number of buckets in the hashtable at the time of creation. The load factor is the ratio of the maximum ratio of elements to buckets. Each time an element is added to a hashtable, the element is placed in a bucket based on the hash value of the key. When a value is retrieved from a hashtable, the correct bucket location is determined by taking the hash value of the key and the bucket elements are searched sequentially for the correct element.
By increasing the load factor, we achieve better memory utilization, but cause the program to be slowed by increased hashing collisions. By decreasing the load factor, we achieve better program speed due to a reduction in hashing collisions, but we get poorer memory utilization, because a larger portion of the hash table remains empty.
Therefore, if I want to add only 30 elements to an Hashtable and I create a new Hashtable by specifying a capacity of 30 elements, I could be sure in avoiding "collision"?
Thanks!