> just wanted to clear something up in my head.
> I am assuming that there will only be one occurence of each word in the hash table. 
>So even though
> the word 'the' may occur several times, it is only listed in the hash table once 
>(and the binary
> tree holds the different occurences of it in the text)....

Yes, that's right.

> SO, to insert into the hash table, is it true that one must first search the hash 
>table, and if
the
> word is not found, insert it with a pointer to a new binary tree
> otherwise, if it is found, just add onto the binary tree where it was found?

Yes.

It's possible (you may or may not find this convenient) to make
insert and search one function, something like

int get(String word, boolean insertIt)

inserting the word if insertIt== true, and else only searching for it,
returning the index of the searched/inserted word in the table, or -1 if you're only 
searching for
it and it's not found.

Note that a prototype like this assumes that the HashTable is assigning hash values to 
the inserted
Strings. You can also calculate hash values outside of the table, and then use a 
prototype similar
to:

Tree get(String word, int hashKey) // for searching
Tree put(String word, int hashKey) // for insertion

There are several ways to design the HashTable interface.

Hans


Reply via email to