Monash University > CSSE > CSE1303 > Part A > Lectures > Lecture A14 notes

CSE1303 Computer Science
Semester 2 2003
Part A
Lecture A14 notes: Hash Tables

In this lecture

Reading: The principles of Hash Tables Hash Functions What is a collision?

The following table contains the probabilities that at least two people in group have the same birthday. This is equivalent to considering the probability that there is at least one collision in a table of size 365, given a number of entries in the table.


Code for this lecture

/*  This is a simple hash function for character strings */
unsigned hash(char* s)
{
 int i = 0;
 unsigned value = 0;

 while (s[i] != ´\0´)
 {
   value = (s[i] + PRIME*value) % TABLESIZE;
   i++;
 }
 return value;
}

[ Top | Home ]
Last Updated: Thursday 26 June 2003 11:05:23