cs 225
play

CS 225 Data Structures Mar March h 13 13 Ha Hashing Wade Fa - PowerPoint PPT Presentation

CS 225 Data Structures Mar March h 13 13 Ha Hashing Wade Fa Wa Fagen-Ul Ulmsch schnei eider er, , Cra Craig Zi Zilles Has Hashi hing ng Has Hashi hing ng Goals: We want to define a keyspace , a (mathematical)


  1. CS 225 Data Structures Mar March h 13 13 – Ha Hashing Wade Fa Wa Fagen-Ul Ulmsch schnei eider er, , Cra Craig Zi Zilles

  2. Has Hashi hing ng

  3. Has Hashi hing ng Goals: We want to define a keyspace , a (mathematical) description of the keys for a set of data. …use a function to map the keyspace into a small set of integers.

  4. Has Hashi hing ng Hash function …

  5. A Hash Table e based ed Dictionary Client Code: 1 Dictionary<KeyType, ValueType> d; 2 d[k] = v; A Hash Table consists of three things: 1. A hash function, f(k) 2. An array 3. Something to handle chaos when it occurs!

  6. A Per erfec ect Hash Function (Angrave, CS 241) Key Value (Beckman, CS 421) (Cunningham, CS 210) Hash function (Davis, CS 101) (Evans, CS 126) (Fagen-Ulmschneider, CS 225) (Gunter, CS 463) (Herman, CS 233)

  7. A Per erfec ect Hash Function Key Value 0 1 2 3 Keyspace: Rolling 5 dice! 4 5 Hash function 6 7 8 9 10 11 12 13 14 15

  8. Has Hash h Func Functi tion Our hash function consists of two parts: • A hash : • A compression: Choosing a good hash function is tricky… • Don’t create your own (yet*) • Very smart people have created very bad hash functions

  9. Has Hash h Func Functi tion Characteristics of a good hash function: 1. Computation Time: 2. Deterministic: 3. Satisfy the SUHA:

  10. Gen ener eral Purpose e Hash Function Keyspaces … Easy to create if: |KeySpace| N ~

  11. Gen ener eral Purpose e Hash Function Keyspaces … Easy to create if: |KeySpace| N ~ Difficult to Create: …

  12. Gen ener eral Purpose e Hash Function Keyspaces … Easy to create if: |KeySpace| N ~ Difficult to Create: …

  13. MP5 P5

  14. MP5 P5

  15. MP5 P5

Recommend


More recommend