Hashing, Hash Tables and Hashing function Flashcards
Another name for a hashing function?
hashing algorithm
What is a hashing function?
A set of rules which is applied to a key field of the data to point to an address or location within a hash table (hash value).
What is a common hashing algorithm?
divide key by the number of cells within a table and take the remainder as the address
What is the purpose of a hashing algorithm and a hash table?
To create an index for the data by transforming the key fields into addresses. It is done to allow quick lookup, deletion or insertion of data.
What is the problem we often experience with a hashing algorithm? What is this called?
The hashed value is equal to a cell location which is already taken. This is called a synonym
What is the name of a situation where two record keys point to the same address or location within a hash table?
a collision
What do we usually do to overcome the collision?
We place the item at the next free space within the hash table
What is a hash table?
a collection of items set out in a way which allows quick access. It is 2d , with one dimension containing the data and the other the key (hashed one)
A hash table is used to…..
to access data in a random way, just like an array
Can hashing be applied to strings?
Yes by searching up the ASCII values of the alphanumeric data
How is a hash table usually implemented?
An array or a list
What makes a good hashing function?
one that tries to avoid getting duplicate data and causing collisions, however this is unavoidable it can be reduced
What does a hash table store?
keys using hash values as an index
Does a hashing function always return the same hashed value for the same keys?
YES, this is because later we will be able to find the location of the key within the hash table
What does storing key values in the next free space come to?
clustering
this increases the likelihood of collisions