Hashes begin with an array. That array is indexed with a mathematical function called a hash function. Since the hash function is based on the key of the element you can jump "close" to the right element very quickly.
The main distinction between types of hashes is in how they handle collisions.
In a closed hash you iterate through the array to find the next open slot in the array.
In a chained hash there is actually a linked list in each slot in the array. Each element is simply added to the list.
Both types of hashes have pros and cons but I'll elaborate those in a later post.
The main distinction between types of hashes is in how they handle collisions.
In a closed hash you iterate through the array to find the next open slot in the array.
In a chained hash there is actually a linked list in each slot in the array. Each element is simply added to the list.
Both types of hashes have pros and cons but I'll elaborate those in a later post.
Comments
Post a Comment