1 / 11

Hashing – Reordering Schemes

Hashing – Reordering Schemes. 1. Open Addressing. All keys stored in the table On collision follow probe sequence Must visit all locations in the table Hash function takes key and probe number h(k,i) : K x {1,2,...} --> {0,1,...,N-1}. 2. Computing Probe Sequence.

nessa
Download Presentation

Hashing – Reordering Schemes

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. Hashing – Reordering Schemes 1

  2. Open Addressing • All keys stored in the table • On collision follow probe sequence • Must visit all locations in the table • Hash function takes key and probe numberh(k,i) : K x {1,2,...} --> {0,1,...,N-1} 2

  3. Computing Probe Sequence • Linear probing: h(k,i) = [h'(k) + (i-1) * c] mod N • Double hashing: h(k,i) = [h'(k) + (i-1) *h''(k)] mod N 3

  4. Comparing Approaches • Average number of probes needed to insert • Average number of probes needed to find • Average number of probes needed to determine a record is not in the table 4

  5. Minimizing Probes Needed to Find • psl – probe sequence length for a key • lpsl – longest probe sequence length 5

  6. Review – Linear Probing 0 1 2 3 4 5 6 7 8 9 10 psl 6

  7. Open Addressing with Reordering • On insertion can move existing elements • Reordering Schemes • Cuchoo hashing • Brent's method • Binary Tree Hashing • Optimal Hashing • Min-Max Hashing • Robin Hood Hashing 7

  8. Brent's Method • On collision • Consider moving both new and existing element • Add psl of two element for each option. • Choose the one with the smallest added psl 0 1 2 3 4 5 6 7 8 9 10 psl 8

  9. Brent's Method - Continued 0 1 2 3 4 5 6 7 8 9 10 psl 9

  10. Binary Tree Hashing • Consider moving any key along the probe sequence • Build decision tree. At each index • Branch left to move the 'new' element • Branch right to move the existing element 10

  11. Binary Tree Hashing - Example 0 1 2 3 4 5 6 7 8 9 10 psl 11

More Related