Hi , do you guys know any good links or tutorials on hash tables since our proffessor didnt do a good job explaining that concept and I have this program to do
http://k4shif.netfirms.com/program4/prog4.html
thanks
Hi , do you guys know any good links or tutorials on hash tables since our proffessor didnt do a good job explaining that concept and I have this program to do
http://k4shif.netfirms.com/program4/prog4.html
thanks
>our proffessor didnt do a good job explaining that concept
A hash table is basically an array. That's not interesting except for the hash function. The hash function doles out numbers that match indexes of the array so that (ideally) each item you want to put into the array can only be hashed into a single unique index. In other words, this is a hash table:
Each character from a to z is hashed to each array index from 0 to 26. That's what a hash table is, a way to take something that isn't an array index and make it into one so that you can access an array quickly and easily.Code:int lettercount[27]; int hash(char c) { /* Assuming ASCII, deal */ return c - 'a'; /* Lower case only */ } int main ( ) { ... while ((ch = cin.get()) != EOF) lettercount[hash(ch)]++; }
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.