1 / 19

Rehashing Techniques

Rehashing Techniques. When collision occur, how do we resolve the problem????. Topic Outline. Addressing Techniques Direct Mapping a.1 Absolute Addressing a.2 Relative Addressing Directory Look-up b.1 Directory Structure as a Table b.2 Directory Structure as a Tree

vicky
Télécharger la présentation

Rehashing Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Rehashing Techniques When collision occur, how do we resolve the problem???? Prepared by Perla P. Cosme

  2. Topic Outline • Addressing Techniques • Direct Mapping a.1 Absolute Addressing a.2 Relative Addressing • Directory Look-up b.1 Directory Structure as a Table b.2 Directory Structure as a Tree • Address Calculation or Hashing • Address Calculation • Rehashing Strategies Prepared by: Perla P. Cosme

  3. Rehashing Techniques • Linear Probing • Two-Pass File Creation • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

  4. Preliminaries To illustrate how each of the different rehashing techniques work, we shall apply these rehashing techniques to a group of words (the words the primary keys). Note: Primary keys need not, be an integer at all times; it may also of character data type. Prepared by Perla P. Cosme

  5. Preliminaries These words were subjected to a hashing function to get their relative positions. The hash(ing) function is described as follows: • Take the ASCII value of each letter in the word. The ASCII table maybe found in almost any Computer Science or IT book; usually found in the appendix. Or, simply download one from the internet. • If not available in the ASCII table, convert the decimal equivalent of the letter into its binary form. Consider only the first 5 significant bits (b4b3b2b1b0) (Why?) • Apply XOR operation to binary numbers of the word. • The result is converted into its decimal equivalent. The decimal number is the relative position. Prepared by Perla P. Cosme

  6. An Example Let the word to be hashed is THE. Then, relative position of the primary key, THE is 25. hash(THE) = ASCII(T) xor ASCII(H) xor ASCII(E) = 101002xor 010002xor 001012 = 110012 = 2510 Prepared by Perla P. Cosme

  7. Let’s try this … Question: Using the same hash function, what would be the relative position of the word OF? Answer: 9 (How did we get the answer?) Prepared by Perla P. Cosme

  8. Hash Function Description If we do the same process (or hashing all the words) to some common words such as those on Table 1, then, we can complete their relative positions, too. (see Table 1 – next slide, please). Prepared by Perla P. Cosme

  9. Table 1. Relative addresses of the Hashed word Prepared by Perla P. Cosme

  10. Some Notes About Table 1 • The relative positions generated from the hash function ranges from 0..29 only. (why?) • The results or the relative positions creates a lot of collisions – best example to handle collision. Prepared by Perla P. Cosme

  11. From this time thereon, we shall refer to Table 1 to illustrate how the different rehashing techniques work. Advise: Keep a copy of the table close to you as we illustrate the rehashing technique. Prepared by Perla P. Cosme

  12. Rehashing Techniques • Linear Probing • Two-Pass File • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

  13. Question How do we handle collisions given the values in Table 1 using Linear Probing Technique? Answer: (Please refer to the board on how the collisions are handled.) Prepared by Perla P. Cosme

  14. Rehashing Techniques • Linear Probing • Two-Pass File Creation • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

  15. Rehashing Techniques • Linear Probing • Two-Pass File Creation • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

  16. Rehashing Techniques • Linear Probing • Two-Pass File Creation • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

  17. Rehashing Techniques • Linear Probing • Two-Pass File Creation • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

  18. Rehashing Techniques • Linear Probing • Two-Pass File Creation • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

  19. Rehashing Techniques • Linear Probing • Two-Pass File Creation • Separate Overflow Area • Double Hashing • Synonym Chaining • Bucket Addressing • Bucket Chaining Prepared by: Perla P. Cosme

More Related