Two folding methods are used: fold shift and 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. For example, imagine we want to
Key
123456789
123
123 456 789
789 321
1 368 123 456 789
987
1 764
(a) Fold shift (b) Fold boundary
Figure 7: Hash fold examples
map identity numbers into three-digit addresses. We divide the nine-digit identity number into three three-digit numbers, which are then added. If the resulting sum is greater than 999, then we discard the leading digit. This method is shown in Figure 7 (a).
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, as seen in Figure 7 (b). It is interesting to note that the two folding methods give different hashed addresses.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment