0

Hi Guys,

Need some help.......

I want 2 read a huge file which contains binary data. Is it possible for me to make use of hash tables to read the same? if so, how can I do it.

If the key value of the hash function is and integer we can mod (%) the same with the size of the table (prime number). But, how can we do the same for binary data?

hash(key) = key % prime

Cheers

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Tom Gunn
0

Hash functions can handle more than just integers. The generic algorithms can hash any collection of bytes you give them:

unsigned int hash(void *key, int sz)
{
    unsigned char *p = (unsigned char*)key;
    unsigned hval = 0;

    for (int x = 0; x < sz; ++x)
    {
        hval = 31 * hval ^ p[x];
    }

    return hval;
}

A good place to start is here.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.