CS 225
Data Structures
Mar March h 13 13 – Ha Hashing
Wa Wade Fa Fagen-Ul Ulmsch schnei eider er, , Cra Craig Zi Zilles
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)
Data Structures
Mar March h 13 13 – Ha Hashing
Wa Wade Fa Fagen-Ul Ulmsch schnei eider er, , Cra Craig Zi Zilles
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.
Hash function …
A Hash Table consists of three things:
Dictionary<KeyType, ValueType> d; d[k] = v; 1 2
Client Code:
(Angrave, CS 241) (Beckman, CS 421) (Cunningham, CS 210) (Davis, CS 101) (Evans, CS 126) (Fagen-Ulmschneider, CS 225) (Gunter, CS 463) (Herman, CS 233)
Hash function Key Value
Hash function Key Value 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Keyspace: Rolling 5 dice!
Our hash function consists of two parts:
Choosing a good hash function is tricky…
Characteristics of a good hash function:
… Keyspaces Easy to create if: |KeySpace| N ~
… Keyspaces Easy to create if: |KeySpace| N ~ … Difficult to Create:
… Keyspaces Easy to create if: |KeySpace| N ~ … Difficult to Create: