Map Hash Tables and Dictionaries_Part_4

Map Hash Tables and Dictionaries_Part_4 - Hash Codes Memory...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
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)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Last 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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Map Hash Tables and Dictionaries_Part_4 - Hash Codes Memory...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online