Pages

what is Hashing in C Language?

Wednesday, 1 January 2014
what is Hashing in C Language?

To discuss ways to grind, and that's essentially what hashing is . The heart of a hashing algorithm is a hash function that takes your nice, neat data and grinds looking at a random integer .

The idea behind hashing is that some data either has no inherent order ( such as images) or is expensive to compare ( such as images). If the data does not inherently control , you can not search for comparison.
If the data are expensive to compare the number of comparisons used even by a binary search may be too . So instead of looking at the data itself, you condense (hash ) the data to an integer ( its hash value ) and keep all data with the same hash value in the same place . This task is performed by using the hash value as an index into a table .

To find an item , simply chop and look at all the data whose hash values ​​match the data you are looking for. This technique significantly reduces the number of elements to look at. If you adjust the settings carefully and enough storage is available for the hash table , the number of comparisons needed to find an item can be arbitrarily close to one.
One aspect that impacts the effectiveness of a request hash is a hash function itself . Ideally, data should be distributed randomly in the hash table to reduce the likelihood of collisions. Collisions occur when two different keys have the same hash value.

There are two ways to solve this problem. Open addressing collision choose another position is fixed in the hash element inserted later. When you look in the hash table , if the entry is not in their position in the hash table , the search continues checking until the element or an empty table position.

The second method of resolving a hash collision is called chaining. In this method , a network or a linked list containing all the elements whose keys hash to the same value . When you look in the hash table , the list must be searched linearly.
Read more ...