Hashing and five popular hashing functions, Data Structure & Algorithms

Assignment Help:

Q. Explain the term hashing? Explain any five well known hash functions.                        

Ans:

Hashing method provides us the direct access of record from the file dosent matter where the record is in the file. This is made possible with the help of a hashing function H which map the key with the corresponding key address. It provides us with the key- to-address transformation.

Five well known hashing functions are as follows:

The Division Method: An integer key x is divided by the table size m and the remainder is occupied as the hash value. This may be defined as

H(x)=x%m+1

Take an example, x=42 and m=13, H(42)=45%13+1=3+1=4

The Midsquare Method: In this a key is multiplied by itself and the hash value is obtained by selecting an suitable number of digits from the middle of the square. The identical positions in the square must be used for all keys. Taking an example, if the key is 12345, square of this key is given by value 152399025. If 2 digit addresses is needed then position 4th and 5th can be chosen, giving address 39.

The Folding Method: In this a key is broken into several parts. Each part has the same length similar to that of the required address apart from the last part. The parts are added together, ignoring the last carry, we get the hash address for key K.
The multiplicative method:  In this technique a real number c  such  that  0

H(x)=[m(cx%1)]+1

In this,cx%1 is the fractional part of cx and [] denotes the greatest integer less than or equal to its own contents.

The Digit Analysis: In this method the addresses is formed by selecting and shifting digits of the original key. For a given set of key, the same positions in the key and same rearrangement of the pattern must be used. By taking an example a key 7654321 is transformed to the address 1247 by selecting the digits in the position 1,2,4 and 7 then by reversing the order.


Related Discussions:- Hashing and five popular hashing functions

Relationship between shortest path distances of modified, a) Given a digrap...

a) Given a digraph G = (V,E), prove that if we add a constant k to the length of every arc coming out from the root node r, the shortest path tree remains the same. Do this by usin

Define tractable and intractable problems, Define tractable and intractable...

Define tractable and intractable problems Problems that can be solved in polynomial time are known as tractable problems, problems that cannot be solved in polynomial time are

..#title, whate is meant by the term heuristic

whate is meant by the term heuristic

Difference between array and abstract data types, Difference between array ...

Difference between array and abstract data types Arrays aren't abstract data types since their arrangement in the physical memory of a computer is an essential feature of their

Different ways for representing s graph, W h at are the different ways by...

W h at are the different ways by which we can represent graph?  Represent the graph drawn below using those ways.     T he d iff e r e nt w a y s by

Algorithm for a function that takes in integer as argument, Write a detaile...

Write a detailed description of a function that takes in an integer as an argument, then prints out the squares of all positive integers whose squares are less than the input. (The

Determine the comparison of gouraud and phong shading, Comparison of Gourau...

Comparison of Gouraud and Phong Shading Phong shading requires more calculations, but produces better results for specular reflection than Gouraud shading in the form of more r

Algo for quicksort, Easy algorithm for beginner for quicksort with explanat...

Easy algorithm for beginner for quicksort with explanation

Create a function to show data structure, Given a number that is represente...

Given a number that is represented in your data structure, you will need a function that prints it out in base 215 in such a way that its contents can be checked for correctness. Y

Explain linked list, Linked List  A linked list is a linear collection...

Linked List  A linked list is a linear collection of data elements called nodes. The linear order is given by pointer. Every node is divided into 2 or more parts.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd