Sunday, September 30, 2018

What is a Hash Table?

HASH Table

A hash table is made up of two parts: an array (the actual table where the data to be searched is stored) and a mapping function, known as a hash function. 

HASH Table is a speedy operation to

(1):Store,

(2):Retrieve

(3):Delete

Hash Function Computes the keys(input values) to generate index:
 

Division Method




key (input)% no. of slots in array = index

Consider an example:


If key is 44  then

44 % 5 = 4



Example

 


So the item 23 will be stored at index 3





Q:What would happen if 2 values comes on the same index ?
If 2 values like 23 and 33 comes on the same index 3 then
 a collision will occur.

 

No comments:

Post a Comment