Hi lighthousedweller-ga,
Okay, the modified program is here:
http://nms.lcs.mit.edu/~gch/google/hashtablestr.tar.gz
Let me know how it works for you.
dogbite-ga |
Request for Answer Clarification by
lighthousedweller-ga
on
04 May 2003 19:34 PDT
OK great thanks a bunch. It works great.
While I have you though I have two questions.
1) oneWord.definition =
oneline.substr(colonindex+1,oneline.length()-colonindex+1); is a part
in the program which finds the defintion. I can't figure out how this
is working though. because the definitions and words sometimes
overlap. like "...fruit to eatbat:a weapon..." how does the program
know to stop after eat for the definition and that bat is a new word?
2) what does labs(hc); do?
3) and just my last question is this and any hashing program relies on
the idea that the keyword you're using to hash is unique, right?
thanks again for your help and quick response yet again.
|
Request for Answer Clarification by
lighthousedweller-ga
on
04 May 2003 19:34 PDT
Make that three questions, ;)
|
Clarification of Answer by
dogbite-ga
on
04 May 2003 20:01 PDT
Hey lighthousedweller-ga,
Sure, I can answer your questions
(all three) :-)
1) oneWord.definition =
oneline.substr(colonindex+1,oneline.length()-colonindex+1); is a part
in the program which finds the defintion. I can't figure out how this
is working though. because the definitions and words sometimes
overlap. like "...fruit to eatbat:a weapon..." how does the program
know to stop after eat for the definition and that bat is a new word?
What do you mean that words and definitions
sometimes overlap? Are you saying the program
isn't working?
Otherwise, the substr() command returns all of
the text on the line after the first colon.
2) what does labs(hc); do?
It just takes the absolute value of hc, which
is a long, hence the 'l.
3) and just my last question is this and any hashing program relies on
the idea that the keyword you're using to hash is unique, right?
Yes, every key (here, word) has to be unique.
thanks again for your help and quick response yet again.
dogbite-ga
|
Request for Answer Clarification by
lighthousedweller-ga
on
04 May 2003 20:40 PDT
Thanks again.
In regards to question one, no the program is working perfectly fine.
You kinda answered my question with: "substr() command returns all of
the text on the line after the first colon."
Because when I was opening the data file in notepad on windows, it was
showing up as all on one line. So i was wondering would substr know to
split the definition and word it up if it was all on one line. But I
opened it with a different text editor, and they appeared on different
lines, as they would have to for this to work. So this makes sense
now.
Last thing, I'm pretty sure about this, but just want to make sure.
The part where you hash the string, you are just trying to convert it
to a random number which you'll then % by another number and use to
put in the hash table. Right?
Thanks for all the help!
|
Clarification of Answer by
dogbite-ga
on
04 May 2003 21:11 PDT
Hey lighthousedweller-ga,
Yes, the hashCode function converts
the string to a number. The number
isn't "random" (that has a strong
mathematical meaning to me) -- it is
a rough binary representation of the
string. But yes, the choice of function
is somewhat arbitrary.
Then we take the module of that number
so it fits in our table.
I'm glad the program is working for you.
dogbite-ga
|