Questions tagged [pset5-hashfunction]

The tag has no usage guidance.

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

pset5/speller Check produces a segfault if I introduce hash function

If I have a single bucket, the program runs seamlessly, however when I introduce the djb2 hash function as seen here the program produces a segfault. Here's my code with the hash function commented as ...
0
votes
1answer
283 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
0answers
68 views

PSET 5 SPELLER - HELP!

i'm not sure why this happens when I execute the code. The program seems to never end as if it's running an infinite loop. When I run valgrind on it misspelled words keep spewing out and it gives me a ...
0
votes
2answers
4k 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
2answers
142 views

Unknown memory leak on “check function” - CS50 Speller

I have trying to decode the information gathered through valgrind with no success. I followed the hints given by valgrind trying too free the malloc'ed node *checker but to no avail. I've searched ...
0
votes
1answer
38 views

pset5 hashtable all words are mispelled, no memory leaking

I have been wrapping my head around this pset for several days and I have no clue on what is causing problems for my code (all words are 'mispelled'). Debug50 hasn't really been helpful :( I suppose ...
0
votes
1answer
105 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 ...
0
votes
1answer
220 views

Pset 5 Speller - Undefined reference to hashValue in load and check

When I compile and run speller, I get the following from the terminal: dictionary.o: In function check': /home/ubuntu/workspace/pset5/speller/dictionary.c:51: undefined reference tohashValue' ...
0
votes
1answer
77 views

PSET5 - dictionary works the same as staff solution, but fails check 50

When I test my dictionary manually with the large dictionary, there are no issues. I even get the correct mispelled words. But if I use check50 or even test with smaller dictionaries, it doesn't seem ...
0
votes
1answer
83 views

PSET5 : My program outputs wrong number of misspelled words

#define MAXH 145709 int total_words = 0; typedef struct node { char word[LENGTH + 1]; struct node* next; }node; node *hashtable[MAXH]; // djb2 by Dan Bernstein unsigned long hash(unsigned ...
0
votes
2answers
116 views

PSET5 Load: Memory allocation while passing / storing strings in Hash Function

Working on speller and have to stop, but would like some help on where I'm stuck. So far, have decided to go with a hash table approach. Assume: 1) I've already created a 2d massive array to store ...
0
votes
1answer
435 views

pset5 load function help. what am i doing wrong?

bool load(const char* dictionary) { int counter = 0; int hash = 0; // define node data type for linked list typedef struct node { char word[LENGTH + 1]; struct node* next; } node; // declare ...
0
votes
1answer
191 views

pset5-Hashfunction using the firste letter of the string

I have been trying to use the first letter of the string for the Hash function i.e int hash = toupper(key[0]}-'A'; as suggested in the website study.cs50.net/hashtables. But Iam getting this Clang ...