Database Reference
In-Depth Information
To illustrate this technique, suppose that the folding method is addition and the
address space is for four digits. Then, we may derive a hash address from the key value of
625149 via one of the following means:
The advantages and disadvantages of folding are similar to those of the mid-square
technique. Figure A2-4 shows a comparison of how both techniques forms on data set
of key-values. For this particular data set, folding appears to distribute the key-values
more gracefully over the address space. On the other hand, the mid-square technique
appears to distribute the key-values more randomly over the address space. Of course,
this simple experiment is not enough for us to make conclusion as to how the techniques
will perform on other data sets.
Figure A2-4. Comparing Folding with Mid-square on a Data Set
A2.2.6 Truncation
In the truncation technique, part of the key is ignored, and the other part is used as the
hash address. To illustrate this technique, suppose that the address space is for four digits.
Then, we may derive a hash address from the key value of 625149 via one of the following
means:
Truncation, like absolute addressing is too simplistic for practical purposes. It could
result in repeated collisions, and it does not come close to distributing the keys evenly
over the address space.
A2.2.7 Treating Alphanumeric Key Values
In many cases, key values will be alphanumeric instead of numeric. For these situations,
you will need to convert the alphanumeric data to numeric form. There are several ways
to do this, so there is no need to panic. Figure A2-5 provides a summary of two commonly
used techniques that have been proposed. Of course, you can come up with your own.
 
Search WWH ::




Custom Search