These are the hashing methods:
Direct method- Modulo-division
- Midsquare
- Digit extraction
- Rotation
- Folding
In direct hashing the key is the address without any algorithmic manipulation.
Direct hashing is limited, but it can be very powerful because it guarantees that there are no synonyms and therefore no collision.
Direct hashing is limited, but it can be very powerful because it guarantees that there are no synonyms and therefore no collision.
Example :
Modulo-division Method
- This is also known as division remainder method.
- This algorithm works with any list size, but a list size that is a prime number produces fewer collisions than other list sizes.
- The formula to calculate the address is:
Address = key MODULO listsize + 1
Where listsize is the number ofelements in the arrary.
Given data
Keys are : 137456 214562 140145
137456 % 19 +1 = 11
214562 % 19 + 1 = 15
140145 % 19 + 1 = 2
Digit-extraction Method
- Using digit extraction selected digits are extracted from the key and used as the address.
- Using six-digit employee number to hash to a three digit address (000-999), we could select the first, third, and fourth digits( from the left) and use them as the address.
379452 -> 394
121267 -> 112
378845 -> 388
Folding Method
Two folding methods are used they are:
2. Fold boundary
94522 = 89340304: address is 3403
Rotation Method
Two folding methods are used they are:
- Fold shift
- Fold boundary
- In fold shift the key value is divided into parts whose size matches the size of the required address. Then the left and right parts are shifted and added with the middle part.
2. Fold boundary
- In fold boundary the left and right numbers are folded on a fixed boundary between them. The two outside values are thus reversed.
Midsquare Method
- In midsquare hashing the key is squared and the address is selected from the middle of the square number.
- Limitation is the size of the key.
94522 = 89340304: address is 3403
Rotation Method
- Rotation method is generally not used by itself but rather is
incorporated in combination with other hashing methods. - It is most useful when keys are assigned serially.
Good amount of detail about various hashing method is provided in this article. I do find this post very helpful. I will share the complete information with all my friends too. Thanks.
ReplyDeleteelectronic signature software
i cannot see the images of example. Can you give the images of eexample
ReplyDeletekindly show me the images. The sufficient amount of information is provided in this article.
ReplyDelete