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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.