Last Updated:
06/02/12 10:23 PM
CSE 2011
Prof. J. Elder
 16 
Hash Codes
Memory address
:
We reinterpret the memory address of the key object as an integer
(default hash code of all Java objects)
Does not work well when copies of the same object may be stored at
different locations.
Integer cast
:
We reinterpret the bits of the key as an integer
Suitable for keys of length less than or equal to the number of bits of
the integer type (e.g., byte, short, int and float in Java)
Component sum
:
We partition the bits of the key into components of fixed length (e.g.,
16 or 32 bits) and we sum the components (ignoring overflows)
Suitable for numeric keys of fixed length greater than or equal to the
number of bits of the integer type (e.g., long and double in Java)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentLast Updated:
06/02/12 10:23 PM
CSE 2011
Prof. J. Elder
 17 
Problems with Component Sum Hash Codes
Hashing works when
the number of different common keys is small relative to the
hashing space (e.g., 2
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '11
 Elder
 Data Structures, hash function, Hash Codes, Prof. J., Prof. J. Elder

Click to edit the document details