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

A full binary tree with 2n+1 nodes, A full binary tree with 2n+1 nodes have...

A full binary tree with 2n+1 nodes have n non-leaf nodes

File organization, Define File organization''s and it''s types

Define File organization''s and it''s types

Algorithm, Define what an algorithm is and outline the characteristics of a...

Define what an algorithm is and outline the characteristics of a good algorithm.

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

Definition of algorithm, Definition of Algorithm Algorithm must have th...

Definition of Algorithm Algorithm must have the following five characteristic features: 1.      Input 2.      Output 3.      Definiteness 4.      Effectiveness 5

Lists, In the previous unit, we have discussed arrays. Arrays are data stru...

In the previous unit, we have discussed arrays. Arrays are data structures of fixed size. Insertion and deletion involves reshuffling of array elements. Thus, array manipulation

Operations on sequential files, Insertion: Records has to be inserted at t...

Insertion: Records has to be inserted at the place dictated by the sequence of keys. As is obvious, direct insertions into the main data file would lead to frequent rebuilding of

Data Structure, Ask consider the file name cars.text each line in the file ...

Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr

Generic doubly linked list, Your objective is to write a generic doubly lin...

Your objective is to write a generic doubly linked list class called CS228LinkedList that implements the List interface and uses a type variable T. All methods except for subList a

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