Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Designing a Hash Function (http://www.programmingforums.org/showthread.php?t=9265)

Twilight Apr 7th, 2006 9:50 PM

Designing a Hash Function
 
Brand new here, so hello, and now onto why I'm here:

For a Comp-Sci class, we have to design a hash table and function to sort 10,000+ English Words into an array, with 9,000-16,000 elements in the Hash Table, using chaining to handle collisions.

But coming up with a good Hash Function is proving rather difficult. Right now I can get a load factor of about .71, but the higher that number goes, the more marks I get, so all suggestions are appreciated :D

DaWei Apr 7th, 2006 9:54 PM

Welcome to the forums. Please take a moment to read the FAQ/rules and possibly a "How to Post..." thread, just to get the feel of the community.

Twilight Apr 11th, 2006 12:36 AM

Well, since my regular folding doesn't seem to be working too spectacularly for me, does anyone know a way to take the ASCII value for more than one char, and use bitwise operations to fold it, like in Encryption algorithms?

nnxion Apr 11th, 2006 2:24 AM

Quote:

Originally Posted by Twilight
does anyone know a way to take the ASCII value for more than one char, and use bitwise operations to fold it, like in Encryption algorithms?

What do you mean by "take the ASCII value for more than one char?"

Narue Apr 11th, 2006 7:55 AM

>But coming up with a good Hash Function is proving rather difficult.
Duh. A lot of brain cells have met their untimely demise trying to come up with a good hash function. It's not easy, and I say that from the standpoint of working for a long time and only coming up with only *one* algorithm suitable for use in a hash table. It's usually better to take an existing hash function and work from there.

This has a list of good (and bad) functions that you can look at and fit to your needs.

Twilight Apr 11th, 2006 11:20 AM

Quote:

Originally Posted by nnxion
What do you mean by "take the ASCII value for more than one char?"

Well, originally, late at night, I was trying to figure out how to put the bit codes for 2 different chars next to each other so I could do easy folds and shifts on them, but I know realize there is a much easier way to do it.


All times are GMT -5. The time now is 9:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC