4 Replies - 515 Views - Last Post: 11 September 2011 - 03:53 PM Rate Topic: -----

#1 Darthlemi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 13-July 11

Question about string hash funtions

Posted 11 September 2011 - 10:45 AM

I need to write a string hash function that puts 3-10 words into each bucket. There are all the words in the English dictionary. Any guidance on where to go for a good research site, or some inside knowledge from this great community would be greatly helpful.
Thanks,
Lemi
Is This A Good Question/Topic? 0
  • +

Replies To: Question about string hash funtions

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6092
  • View blog
  • Posts: 23,612
  • Joined: 23-August 08

Re: Question about string hash funtions

Posted 11 September 2011 - 12:43 PM

Gee, if only there were a SEARCH function on this forum, you might've found this!
Was This Post Helpful? 0
  • +
  • -

#3 Darthlemi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 13-July 11

Re: Question about string hash funtions

Posted 11 September 2011 - 03:36 PM

View PostJackOfAllTrades, on 11 September 2011 - 12:43 PM, said:

Gee, if only there were a SEARCH function on this forum, you might've found this!


Well i mean like i have not searched this forum for one. The problem is i don't really know how to write my own for strings. I currently have one that looks like this
int hash(const string& str)
{
	// loops throught the length of the string
	unsigned int h=0;
	for (int i = 0; i < str.length() + 1; ++i)
		
		h= h * i + str[i];

	return h % 33;
}





The only thing is i don't really know what the h = h * i + str[i]; is doing and why its doing it like that.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is online

  • member icon


Reputation: 4232
  • View blog
  • Posts: 13,290
  • Joined: 25-December 09

Re: Question about string hash funtions

Posted 11 September 2011 - 03:40 PM

You may want to review how Arrays and Character Sequences work.

Jim
Was This Post Helpful? 0
  • +
  • -

#5 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1623
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Question about string hash funtions

Posted 11 September 2011 - 03:53 PM

you might look at the Pearson Hash also.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1