Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 7th, 2006, 10:50 PM   #1
Twilight
Programmer
 
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3 Twilight is on a distinguished road
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
Twilight is offline   Reply With Quote
Old Apr 7th, 2006, 10:54 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Apr 11th, 2006, 1:36 AM   #3
Twilight
Programmer
 
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3 Twilight is on a distinguished road
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?
Twilight is offline   Reply With Quote
Old Apr 11th, 2006, 3:24 AM   #4
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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?"
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Apr 11th, 2006, 8:55 AM   #5
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>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.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Apr 11th, 2006, 12:20 PM   #6
Twilight
Programmer
 
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3 Twilight is on a distinguished road
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.
Twilight is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:38 AM.

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