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

Write procedure to the insert a node into the linked list, Q. Write a proce...

Q. Write a procedure to the insert a node into the linked list at a particular position and draw the same by taking an example?

Multidimensional array, Q. The system allocates the memory for any of the m...

Q. The system allocates the memory for any of the multidimensional array from a big single dimensional array. Describe two mapping schemes that help us to store the two dimensi

Usage of linked lists for polynomial manipulation, Q. Establish the usage o...

Q. Establish the usage of linked lists for polynomial manipulation.                                       Ans. Usag e of Linked List for Polynomial Manipulation. Link

Array implementation of a queue, Since the stack is list of elements, the q...

Since the stack is list of elements, the queue is also a list of elements. The stack & the queue differ just in the position where the elements may be added or deleted. Similar to

The # of times an algorithm executes, for(int i = 0; i for (int j = n -...

for(int i = 0; i for (int j = n - 1; j >= i ; j--){ System.out.println(i+ " " + j);

Develop a material requirements plan, The below figure illustrates the BOM ...

The below figure illustrates the BOM (Bill of Materials) for product A. The MPS (Material requirements Planning) start row in the master production schedule for product A calls for

Quicksort and bubble sort algorithms, Task If quicksort is so quick, w...

Task If quicksort is so quick, why bother with anything else? If bubble sort is so bad, why even mention it? For that matter, why are there so many sorting algorithms? Your

Explain backtracking, Explain Backtracking The  principal idea is to co...

Explain Backtracking The  principal idea is to construct solutions single component  at a time  and evaluate such  partially constructed candidates as follows. If a partiall

Technique for direct search, Technique for direct search is    Hashing ...

Technique for direct search is    Hashing is the used for direct search.

Algorithm to add element in the end of circular linked list, Q. Write down ...

Q. Write down an algorithm to add an element in the end of the circular linked list.        A n s . Algo rithm to Add the Element at the End of Circular Linked Lists

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