Questions tagged [pset5-hashfunction]
The pset5-hashfunction tag has no usage guidance.
16
questions
0
votes
1
answer
33
views
Speller perfomance question
I've completed speller and passed all checks. But I'm still bugged about the performance. I did my best with research and running tests, but my implementation is slower by 10-20% compared to staff's ...
0
votes
1
answer
35
views
I just can't figure out how to put the word into lowercase for the hash function to provide the same index
bool check(const char *word)
{
char mot2[46];
for (int o = 0, h = strlen(word); o < h + 1; o++)
{
mot2[o] = tolower(word[o]);
}
int y = hash(word);
node *cursor = table[y];
while (cursor != ...
0
votes
1
answer
48
views
dictionary.c - pset5 segmentation fault
// Implements a dictionary`'s functionality
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
...
0
votes
1
answer
76
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 ...
2
votes
1
answer
3k
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
0
answers
126
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 ...
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
2
answers
205
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
1
answer
40
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
1
answer
127
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
1
answer
242
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
1
answer
85
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
1
answer
91
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
2
answers
130
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
1
answer
459
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
1
answer
561
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 ...