Hashing and hash functions, Data Structure & Algorithms

Assignment Help:

Q. Describe the term hashing. Explain any two usually used hash functions. Explain one method of collision resolution.                                                                                                     

Ans.

A hash table is a data structure in which the location or address of a data item is determined directly as a function of data item itself instead of by a sequence of comparison. Under ideal condition, the time needed to find a data item in a hash table is

0(1) ie. it is constant and documents does  not depend on the number of data items stored in it.

When the set of K of keys saved is much smaller than the universe U of all the probable keys, a hash table need much less storage spare than a direct address table.

Hash Function is described as follows

A hash function h is simply a mathematical or calculative formula that manipulates the key in some form to compute or calculate the index for this key in the hash table. Eg a hash function can split the key by some number, generally the size of the hash table and return remainder as the index for the key. Commonly, we say that a hash function h maps the universe U of keys into the slots of a hash table T[0....n-1]. This process of mapping keys to appropriate slots in a hash table is called as hashing.

A hash function h is generally a mathematical or calculative formula that manipulates the key in some form to compute or calculate the index for this key in the hash table. Eg a hash function can split the key by some number, generally the size of the hash table and return remainder as the index for the key. Commonly, we say that a hash function h maps the universe U of keys into slots of a hash table T[0....n-1]. This process of mapping keys to appropriate slots in a hash table is called as hashing.

 (a) Division Method is given as follows:- In this process, key K to be mapped into one of the m states in the hash table is separated by m state in the hash table is divided by m and the remainder of this separation taken as index into the hash table. The hash function is as follows

h(k) = k mod m

where mod is the modules operations performed.

(b)    Multiplication Methodis described as: The multiplication method or technique operates in 2 steps. In the 1st step the key value K is multiplied by a constant A in the range O

h(k) = [m (K A mod 1)]

Methods of Collision Resolution are stated below

1)      Collision Resolution by the separate chaining

2)      Collision Resolution by an open addressing

 

1)      In this scheme all elements whose key hash to same hash table slot are put in a related list. Thus the slot in the hash table comprises a pointer to the head of the related list of all the elements that hash to value i. If there is no such element that hash to value I , the slot I comprises the NULL value ( pictures as X)

1889_collision resolution.png


Related Discussions:- Hashing and hash functions

Explain in detail about the abstract data type, Abstract data type The ...

Abstract data type The thing which makes an abstract data type abstract is that its carrier set and its operations are mathematical entities, like geometric objects or numbers;

Linked lists, what are grounded header linked lists?

what are grounded header linked lists?

Explain stacks, What are stacks? A stack is a data structure that organ...

What are stacks? A stack is a data structure that organizes data similar to how one organizes a pile of coins. The new coin is always placed on the top and the oldest is on the

Deletion of an element from the linked list, A LGORITHM (Deletion of an ele...

A LGORITHM (Deletion of an element from the linked list) Step 1  Begin Step 2  if the list is empty, then element cannot be deleted Step 3  else, if the element to be del

Define big omega notation, Define Big Omega notation Big Omega notatio...

Define Big Omega notation Big Omega notation (?) : The lower bound for the function 'f' is given by the big omega notation (?). Considering 'g' to be a function from the non-n

Calculate address of an element in an array., Q. Explain the technique to c...

Q. Explain the technique to calculate the address of an element in an array. A  25 × 4  matrix array DATA is stored in memory in 'row-major order'. If base  address is 200 and

Explain the array and linked list implementation of stack, Question 1. ...

Question 1. How can you find out the end of a String? Write an algorithm to find out the substring of a string. 2. Explain the insertion and deletion operation of linked lis

Create a binary tree , Create a class "box" that will contain a random inte...

Create a class "box" that will contain a random integer value v such that O

Define an array, Define an array. Array is made up of same data structu...

Define an array. Array is made up of same data structure that exists in any language. Array is set of same data types. Array is the collection of same elements. These same elem

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