Hashing

 

Overview

 

Hashing quality measures

 

Some hash table size selection methods

1. size is prime number

2. Size is 1.5 times the expected maximum number of required addresses.

3. Experiments and experience show that these work well

 

Collisions occur in two situations

1. Insert new key, and hash yields address already occupied.

2. Retrieve based on key, and key value at hashed address does not match

These are equivalent situations, so we will concentrate on insertion

 

What to do when collisions occur upon insertion?

There are several plausible alternatives.

1. Open-address Hashing (a.k.a. open hashing, linear probe)

2. Quadratic processing

3. Double Hashing.

4. Chained Hashing (a.k.a. separate chaining)

5. Bucket hashing

 

Two notes about hashing in Java

1. All java classes derived from Object have a method called hashCode which will translate the object value into an integer suitable for sending into a hash function.

2. Java provides the Hashtable class so you can use hashing without having to roll your own.

 

 

Some hash function design methods

1. Base on sound random number generation techniques

2. folding

3. digit/character extraction

4. modulo

5. combinations of 1-4.


[ Lectures | CSC 132 | Peter Sanderson | Computer Science | SMSU ]


Last reviewed: 29 November 2000

Peter Sanderson ( PeteSanderson@smsu.edu )