Questions tagged [hash-function]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
51 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
3answers
68 views

PSET 5 Hash help

I started my load function without looking at any reference code (first time starting a pset this way) to give me an idea on how to implement my own version. I was mostly confident until I reached the ...
0
votes
1answer
42 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
0answers
56 views

Shows double free or corruption (fasttop)

// Implements a dictionary's functionality #include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include "dictionary.h" // Represents a node in a ...
0
votes
2answers
2k 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
0answers
60 views

PSET5 Valgrind Problem!

I have my code semi working (it passes most of the check50) except Valgrind keeps reporting 'Invalid read of size 1' . Here is a screenshot of the error message: . I used the djb2 hash function. ...
1
vote
1answer
139 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
1answer
75 views

Speller Valgrind leaks bytes + error: munmap_chunk(): invalid pointer error in C

Check50 gives me the munmap_chunk: invalid pointer - it seems I am not copying something right with strcpy. Valgrind gives me: LEAK SUMMARY: still reachable: 608 bytes in 2 blocks ==2864== 56 bytes ...
0
votes
1answer
83 views

PSET4 free on malloc in hash function

I'm trying to improve my hash function in Speller and I'm having trouble freeing allocated memmory. I'm getting * Error in `./speller': free(): invalid pointer: 0x0000000001a02252 * Aborted I know ...
0
votes
1answer
53 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
1answer
1k views

PSET5: Hash function returning collisions

Looking for advice on hash functions and strings. For PSET5, I decided to implement a trie but instead of storing [a - z] in each node, only storing [0 - 9]. For this to work, I hashed the words and ...
0
votes
1answer
100 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
281 views

Check function too slow in pset5

I've completed "Speller" successfully, but have been trying to optimise it as the run time for "check" is significantly longer than the staff solution. I suspect the reason is that I don't have ...
0
votes
1answer
195 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
3answers
53 views

16 letter words show up as misspelled from Pset5

I found this great hash function. But I noticed something very weird during pset5. When I am testing my program by putting the outputs of my program and the staff solution into student.txt and staff....
0
votes
2answers
169 views

Pset5 speller - load clang error (linker command error) and multiple definition

I typed make speller and clang produces the output below. I'm really not sure how to resolve this. I thought that it might be saying that I defined the hash function twice but I don't think I have. ...
0
votes
1answer
574 views

Is this hash function valid?

I just wonder if this hash function is correct? I was thinking that the index cannot be above 26 as it would look for memory outside the array, and would probably cause a segmentation fault. Therefore ...
0
votes
1answer
82 views

PSET5: Hash function and code not handling possessives and substrings

I am having a lot of problems with pset5. I have identified more than one issue with the code but I don’t know how to fix the issues. The first is from my hash function, which is featured below and I ...
0
votes
1answer
442 views

Why does this hash function fail?

unsigned int hash(const char *str) { unsigned int hash = 5381; int c; int i; size_t k= strlen(str)*1; char *str2=malloc(k+1); strcpy(str2,str); for(i=0;i<strlen(str);i++...
0
votes
1answer
464 views

Segmentation fault occurs if I delete an unused global variable in Pset5

It looks I have broken C while working on Pset5, I mean, I don't understand a bit why this happens. First, I completed the problem with the simplest of hash functions which just processes the first ...
0
votes
1answer
881 views

Problems with hash function in pset5

I'm using a hash function I found online that's meant to be quick but it's throwing an error that I don't understand (and as I've cut and paste it, I don't get what the issue can be?). Everything else ...
0
votes
2answers
1k views

pset5 load, hash function , lost :(

i am a beginner and wanted to solve the pset with hashfunction and than a linked list. I wanted to start out with the simplest way i can thought of. One bucket for every letter in the alphabet. Here ...
1
vote
1answer
595 views

Pset6: Is it possible implement a 3D Hash table Matrix?

It might be too early on for me to ask questions in this problem set, as I am just getting started with load. I was looking up Hash Functions, and they look a little cryptic to me. Is it possible to ...