diff options
Diffstat (limited to 'wk5/pset/speller/dictionary.c')
-rw-r--r-- | wk5/pset/speller/dictionary.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c index cf2d6d1..c095ad4 100644 --- a/wk5/pset/speller/dictionary.c +++ b/wk5/pset/speller/dictionary.c @@ -26,10 +26,25 @@ int siz = 0; // Returns true if word is in dictionary, else false bool check(const char *word) { - // TODO + // hash word to find bucket + int val = hash(word); + node *current = table[val]; + + // check all nodes in the bucket + while (current != NULL) + { + // check if this is the word + if (strcmp(current->word, word) == 0) + { + return true; + } + current = current->next; + } + return false; } + // Hashes word to a number unsigned int hash(const char *word) { |