As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [hash-table]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
24 views

Pset4: dictionaries with hashtable -- every word is misspelled

I'm getting every word is misspelled when I run ./speller dictionaries/large texts/pneumonoultramicroscopicsilicovolcanoconiosis.txt When I run help50: Sorry, help50 does not yet know how to help ...
0 votes
1 answer
244 views

CS50 Pset5 Speller

I am having problems with Pset 5 Speller. I believe, I'm nearly there, I can get all functions to run and compile successfully, however my outputs are not quite right. I have attached comments to make ...
1 vote
1 answer
425 views

My check function in speller isn't working

I have implemented everything else but this check function when I try to test it it seems like the the check function isn't working, because the no. of misspelled words is the same as the no. in text.....
0 votes
1 answer
26 views

Why am I able to insert an element into a hash tree via Main() but not via a function call?

I'm fairly certain this has something to do with pointers and the function using copies instead, but I'm not sure how...because I've inserted the pointer as a parameter for create(); #include <...
0 votes
1 answer
44 views

"check" function in pset4, problem with hashtable and pointers

I'm getting an pesky error when trying to compile my code. error: use of undeclared identifier 'hashtable' first = hashtable[i]; My code, per below, is an attemp to implement the check function ...
0 votes
1 answer
258 views

pset6 load seg faulting when accessing malloc'd node

I need some guidance on where I'm going wrong here. GDB runs fine until I try to access the "next" property of a node to see if it's NULL. Am I just confusing how the node structure works? My ...
0 votes
1 answer
74 views

PSET 5 My hash table doesn't seem to be storing correctly

When I load the dictionary, I add the words to the hash table, by calling the hash function to calculate the bucket ID, then add hash function to actually insert it into the list. Inside the addhash ...
0 votes
2 answers
519 views

How can I debug my load() function in Speller?

So I have code that I feel as though should be working, but I'm having trouble checking my work. I wrote a function that I think loops through my table, but it only displays half of the data seemingly....
0 votes
1 answer
286 views

CS50 pset 4 speller - qualifies for bigboard

My code qualifies with check50, valgrind and style 50. But when I want to submit it to big board it says "timed out while waiting for program to exit" Here's my dictionary.c - // Implements a ...
0 votes
1 answer
15 views

I can't reproduce a behavior to the hash table and the first node

1st. In dictionary.c the line: node *table[N]; declares an array of pointers or an array of nodes? 2nd. When I code: table[index] = n; table receive a value for ->word and ->next? or just ...
0 votes
1 answer
247 views

Speller not working! What's going on?

My function returns this: WORDS MISSPELLED: 375902 WORDS IN DICTIONARY: 143091 WORDS IN TEXT: 376904 TIME IN load: 0.02 TIME IN check: 1.20 TIME IN size: 0.00 TIME ...
1 vote
2 answers
7k views

PSET5 Speller hash function

I have been working on the speller problem in pset5 for a while now, and I am not able to figure out the problem in my hash function: unsigned int hash(const char* word) { int M = 1000000001; ...
0 votes
1 answer
470 views

When declaring an array of pointers that will be a hash table, do you have to set all the elements of the array to NULL?

In the distribution code for Speller in pset5, they include this line in dictionary.c // Hash table node *table[N]; Should I set every element in the array to NULL, because they are pointers? (the ...
0 votes
1 answer
46 views

Speller skips last word in testfile I use

The title speaks for itself, but here is a bit more in-depth explanation. While my check() function runs, it always skips the last word in whatever file it is checking out. The source code for my ...
0 votes
1 answer
64 views

I can't assign a node to a bucket in a hash table with with right assignment of pointer and word values

When I assign table[index3] = n; what happens is that the value of the word receives a memory address and I can't follow table[index]->next to achieve the old n->word; This shouldn't happen. // ...
0 votes
1 answer
65 views

CS50 (Speller) returns all words as misspelled

I'm right on the verge of cracking this problem. I ran the program on the small dictionary provided in the distribution code. It returned both words as misspelled. So I debugged the program. I noticed ...
0 votes
1 answer
151 views

PSET5 Compiling issue

So I finally finished my code and received 20 errors when attempting to compile, after my first attempt fixing the errors I tried again and received 15 errors, once more and received 17, and now am ...
2 votes
1 answer
5k views

CS50 good hash function for PSET5 Speller

I was looking up different hash functions and was getting really confused following what the code was doing. I stumbled upon this hash function: int hash(const char * str) { int hash = 401; ...
0 votes
1 answer
68 views

Pset5 Speller: every word in text reported as misspelled

Code compiles, dictionary loads and unloads, word count works and hash function seems to work. However, the results show that every word in the text is misspelled. I’ve spent 3 weeks tweaking the code ...
0 votes
1 answer
60 views

Speller.c doesn't work

I've spent pretty much time trying to solve a speller and got really stuck, don't know what's wrong with my code. It compiles but check50 says it's totally incorrect. I would be grateful if you could ...
0 votes
2 answers
1k views

pset4 Speller hash table basics

After struggling with this pset for a while I decided to strip it down to its most basic form and try and understand the implementation of hash tables and linked lists by creating my own. To that end ...
0 votes
1 answer
52 views

on pset4 speller load() struggling to understand if populating dictionary correctly and how to check hashtable

I am building my load() function and I'm wondering if I'm building it so that it is indeed storing the dictionary words correctly. I tried printing both: printf("%s\n", new_node->word); //to see ...
0 votes
1 answer
75 views

speller double free or corruption hashtable

I'm getting a "double free or corruption" error when running this code. I don't know in which function the error is. I get the error after the code has run through check, before it gets to the unload ...
0 votes
2 answers
184 views

Speller (Hash) not handling substrings properly

All tests seem to pass okay apart from the substrings test.The results of this test are : :( handles substrings properly expected "MISSPELLED WOR...", not "MISSPELLED WOR..." Log running ./...
0 votes
1 answer
51 views

do not understand why check function checks new word against dictionary

I am trying to implement the check function of Speller in CS50. The code below may or may not work. But the thing that gets me is that I don't understand the bit : if strcasecmp(cursor-> word, ...
0 votes
1 answer
3k views

I keep getting the message that 'non-ASCII characters are not allowed outside of literals and identifiers.'

I keep getting the message that 'non-ASCII characters are not allowed outside of literals and identifiers.' I get this message when I compile and it is at the strcpy section. Any help gratefully ...
0 votes
1 answer
160 views

CS50 [Speller_hashtable] my hashtable is weird!

After debugging for a long long time, it turned out that my hashtable must have some problem. Therefore, to find out where the problem is, I put this line of code after I insert a word in the ...
0 votes
1 answer
149 views

PSET4 (Speller) malloc and calloc usage

After getting my code to work, i looked if there were any memory leaks using valgrind. It found no memory leaks, however it returned these two errors: ==7109== Conditional jump or move depends on ...
0 votes
1 answer
524 views

Speller (hash) memory leak?

The program seems fine to me (other than this, it runs as intended), when I run valgrind, it says: ==5101== Memcheck, a memory error detector ==5101== Copyright (C) 2002-2017, and GNU GPL'd, by ...
0 votes
1 answer
69 views

I can't figure out what's wrong with my speller (hash) code

When I try to run it, it says that there are no words in the dictionary so there's probably something wrong with the load function. My load code: // Loads dictionary into memory, returning true if ...
0 votes
1 answer
94 views

Speller(hashtable) VALGRIND ERRORS!

i don't know or understand through val grind where and what i'm doing wrong. Except for memory errors my code outputs as correct in check50. my code // Implements a dictionary's functionality #...
0 votes
2 answers
557 views

PSET4 Speller(hashtable) cs50 2019 HELP!

Can somebody please help me whenever i execute check50 on my code i get this :( handles most basic words properly expected "MISSPELLED WORD...", not "MISSPELLED WORD..." :( handles min length (1-...
0 votes
1 answer
325 views

PSET 4 - Speller: Every single word is misspelled

When I run the program, all words are considered misspelled. I can't figure out where the problem is. Can someone please help me? It also says that my program is free of memory errors - can't check ...
10 votes
3 answers
1k views

pset4 speller - can't pass valgrind test - 32 bytes still reachable

Can't pass valgrind test on pset4 speller (hashtable). The speller works perfectly but, I'm getting this message from valgrind: ==3911== ==3911== HEAP SUMMARY: ==3911== in use at exit: 32 bytes ...
0 votes
0 answers
153 views

Speller - Valgrind - Blocks Are Still Reachable

Valgrind indicates 32 bytes in 1 block still reachable. My speller seems to work in all other respects based on my own testing and Check50 (except final memory check). Since I do not see any valgrind ...
0 votes
2 answers
563 views

pset4 speller all words are misspelled

I realize that many people have asked this question before but I didn't find my answer in any of them. Or maybe I'm just too stupid to see it. Anyways my code seems to work except that all the words ...
0 votes
1 answer
471 views

PSET5 "Linker Command Failed with Exit Code 1"

I've been working on speller (implementing a hashtable) for quite a while now and I'm stuck...my code compiles but I'm assuming there's a run-time error. I'm not sure what to make of my error message, ...
0 votes
1 answer
140 views

CS50 - Speller (Hashtable) - Misspelled all words

My program is misspelling all words in the texts. There is a problem somewhere in either load or check, but I just can't figure it out. Can you guys help me find the problems I am having in my program?...
0 votes
1 answer
394 views

Speller 2019: dictionary could not be unloaded and the program identifies misspelled words wrongly

my code does not work so well because it could not unload the dictionary/large eventhough there are no leaks in memory. My programm does also identify the misspelled words wrongly. Just comment if ...
1 vote
1 answer
163 views

Pset5: Hashtable, cannot submit my code

I am unable to submit my code to test it against other cs50 students :) dictionary.c and dictionary.h exist :) speller compiles :( qualifies for Big Board expected exit code 0, not 139 How ...
0 votes
1 answer
27 views

There seems to be some problem with loading words from a dictionary into a Hashtable, It compiles fine but does not give the expected output

Whenever i run the program it always displays number of words in dictionary as 26. When i try to debug using debug50 loading looks fine but when i debug the size part it display 0x0 against the next ...
0 votes
1 answer
411 views

CS50 Speller (hash table) - Check returning 0 misspelled words

I'm looking for help with my (hash) code in check to properly handle misspelled words with apostrophes and substrings: bool check(const char *word) { int len = strlen(word); char copy[len + 1]; ...
0 votes
1 answer
74 views

pset5 speller program doesn't display benchmarks

When I ran my code through the compiler, it displays all the misspelled word correctly as per the staff solution. However, the program does not end after displaying all the misspelled words and it ...
0 votes
1 answer
140 views

pset5 load null pointer issue

Working through the load portion of pset5. Everything compiles, but when I run valgrind it looks as if nothing is actually loading in, with the error of "null pointer passed as argument 1, which is ...
2 votes
2 answers
131 views

how effective would it have been to use an array for the dictionary?

I just completed pset5 using a trie, but I'm curious about other methods. How effective would it have been to load the dictionary into an array and then use a binary search function to locate words ...
0 votes
1 answer
135 views

HashTable full of single value

I think the problem is in my load function. I am able to successfully create a hash for each word, and I can call my createNode and insertNode functions to such a degree that I create a full hashtable ...
0 votes
1 answer
123 views

Two hash table questions

I am working through SPELLER and have a few questions. When I create a new node node *newptr = malloc(sizeof(node)); do I need to say newptr1, newptr2, newptr3 and if so what is the best way of doing ...
0 votes
1 answer
722 views

Struggling with hash table! Pset5

I've been trying to fix this bug for the past couple of days, but it seems this one I really can't figure out on my own. Hope you guys can help a bit. Here's the code for my load function in pset5. #...
0 votes
1 answer
229 views

pset5 speller: loads one more word

Whenever I load words from the dictionary and check the number of words in the dictionary, it seems to load one more than there actually is. For example, if I load the SMALL dictionary, number of ...
0 votes
0 answers
65 views

Printf prints newline character instead of string in Pset5

I'm working on the Speller program in Pset5. As always, i'm using a modular approach to construct all the required constituent functions one by one. However, something quite odd is happening in my ...