Tuesday, 10 July 2012

Hash Function : Folding


Two folding methods are used they are:
  • Fold shift
  • Fold boundary


5.1 Fold Shift
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.

5.2 Fold Boundary
Fold Boundary
In fold boundary the left and right numbers are folded on a fixed boundary between them and the center number. The two outside values are thus reversed.

If the need is to generate a 5 digit address then make units of 4 digits and add them which will make a 4 or 5 digit address.

If the records will be less than 999 then use 1764. If records will be near to 9999 then use 13221. Fold and achieve expected size of address space. The loading factor will be 999/1764 = 0.57

No comments:

Post a Comment

Your comments are very much valuable for us. Thanks for giving your precious time.