Solved

# Hash tables

Posted on 2000-03-27

Hi. I'm trying to implement the following hash functions.

1. h(x)= 1 + (x/k) * M

2. h(x)= 1 + x mod M

3. h(x)=1 + @x mod M

Where M is the table size. They should change keys into integers in the range from 1 to M. I'm using this to generate the numbers and send them to the hash function:

#include<iostream.h>

#include<stdlib.h>

main()

{

int tablesize=32;

int a[200];

for(int i=0;i<200;i++)

{

i=rand()%5001;

h(x)=hash(tablesize,i)

}

return 0;

}

1. How do I make the hash function?

2. Can hashing be used with text? Can you provide some examples?

Thanx