summaryrefslogtreecommitdiff
path: root/wk5/pset/speller/dictionary.c
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-29 02:38:04 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-29 02:38:04 +0000
commit65482246eb5a13207c06a91f8c0939f5eea8eeb5 (patch)
tree358ff4009e2446064fa8e63f7bfeab2aac348dc2 /wk5/pset/speller/dictionary.c
parent8330ab3cfc6611739cf6ee83968f32c97be549d5 (diff)
Sun, Apr 28, 2024, 7:38 PM -07:00
Diffstat (limited to 'wk5/pset/speller/dictionary.c')
-rw-r--r--wk5/pset/speller/dictionary.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c
index 2accd1b..20053fe 100644
--- a/wk5/pset/speller/dictionary.c
+++ b/wk5/pset/speller/dictionary.c
@@ -65,7 +65,7 @@ bool load(const char *dictionary)
{
// initialize the table
for (int i = 0; i < N; i++) {
- table[i] = 0;
+ table[i]->next = 0;
// table[i]->word = "";
}
@@ -100,14 +100,14 @@ bool load(const char *dictionary)
// hash the word to find the bucket it goes in
int val = hash(ptr->word);
// put new node at begining of bucket
- if (table[val] != 0)
+ if (table[val]->next != 0)
{
- ptr->next = table[val];
- table[val] = ptr;
+ ptr->next = table[val]->next;
+ table[val]->next = ptr;
}
else
{
- table[val] = ptr;
+ table[val]->next = ptr;
}
}