Questions tagged [pset5]
The problem set for Week 5 will challenge you to apply what you've learned about pointers, memory management, file i/o and structs, creating more complex data structures (such as Hash Tables or Tries) and leveraging their power to write a lightning-fast spell check algorithm.
1,179
questions
0
votes
1answer
6 views
PSET 5: valgrind: memory marked as 'still reachable'
fortunately I finally made it through speller. The only thing remaining is a valgrind error:
==2226== HEAP SUMMARY:
==2226== in use at exit: 8,013,096 bytes in 143,091 blocks
==2226== total heap ...
0
votes
1answer
20 views
pset 5 - speller: Hash function gets stuck with strlen() and I don't know why. Furthermore I'm lacking memory
I have several problems with my speller code and debug50 wont help me. I sat in front of it for hours now. Just want to know, where to start. Have no clue.
At first Debug50 gets stuck at strlen() in ...
0
votes
3answers
35 views
PSet 5 Speller: How can the program tell if the dictionary has been successfully freed?
I'm pretty sure I'm just being dumb, but I've been wracking my brain and I'm drawing a blank. I've completed 5/6 of the functions in Speller, but the unload function has me stumped- the description ...
0
votes
2answers
38 views
Speller.c, get correct result on my machine, wrong on check50
Good day,
I am struggling with speller.c. When I run the program on my machine I get the correct result compared to the keys but then when I use check50 to check I get all wrong.
I have narrowed the ...
0
votes
1answer
60 views
Output in Speller.c seems to match the staff solutions, but cannot seem to pass check50
This is what I happen to get when I run check50, which is weird, because when I do manual tests, I seem to match the keys.
Other posts make me think this might be an issue of using the incorrect slug? ...
0
votes
1answer
33 views
lab 5 // issue when freeing family memory
Hi I have an issue with freeing the family memory in my code:
when I run my code the issue seems to be from the free memory for the parents section but I am not sure what's wrong
void free_family(...
0
votes
1answer
29 views
pset5 - speller - recursion
// Implements a dictionary's functionality
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "dictionary....
0
votes
1answer
16 views
Pset5 - Speller - Seg fault
I'm getting a segmentation fault when running this. Valgrind reports no errors, but a leak of 1,080 bytes at two blocks, with 5 allocs and only 3 free'd. Below is my load function and below that are ...
1
vote
1answer
30 views
Pset 5 Output to file different from terminal output
I'm stuck on Speller... the code compiles and provides the same output as the staff solution when the output is redirected to a file,
as instructed, to:
$ ./speller texts/lalaland.txt > student.txt
...
0
votes
2answers
49 views
Pset5 - Speller - Valgrind error for malloc in load function
I get all test results correct except the Valgrind error as follows, does anyone know why is it so and share some insights please? thanks!
running valgrind --show-leak-kinds=all --xml=yes --xml-file=/...
0
votes
1answer
19 views
Uninitialized values in PSET5
I've looked through all the various answers but I can't seem to figure out what the issue is... I understand that I can't reference values that may not be initialized but I don't understand how else ...
0
votes
1answer
29 views
Pset 5 speller load function and word
I'm working on my load function to obtain the "word" from dictionary and I obtain one of the next message
dictionary.c:59:28: error: use of undeclared identifier 'word'; did you mean 'load'?
...
0
votes
2answers
36 views
Pset5 Speller,Check function isn't working as expected, strcasecmp always returns false
The problem is the word is found in loaded dictionary it's found but check function still returns false
i've been like 7 days in this problem someone helps please,
((I'm Trying to test code ./speller ...
0
votes
1answer
28 views
speller is case sensitive
I tried to convert each word to lower before hashing in check, but it seems like it didnt do anything :( however, in the output the misspelled word is now lower
// Implements a dictionary's ...
0
votes
1answer
37 views
PSET5/Speller - Valgrind error: conditional jump, relates to table[i] array, but I've already initialized that (or have I?)?
I posted something similar a couple of days ago but have made progress since then. Specifically I found a couple of posts answered by Cliff B indicating the problem users had was that they hadn't ...
0
votes
1answer
17 views
speller getting different hashes in check and load
using some printf statements to debug it seems that when I hash a word in my load function I get a different value then when I hash it in my check function, even when the words are the same case. I'm ...
0
votes
1answer
23 views
speller returning a segmentation fault, unclear why
this is my dictionary.c implementation. I think the problem is speller since I've been printing my hash values from hash. I also have not yet implemented unload since I think I'm having some ...
0
votes
1answer
20 views
My program tells me there are no words misspelled when I use the large dictionary, although the small dictionary with cat.txt seems to work fine
My code passes all the check50 checks, apart from a small amount of memory leak (I think I'm unnecessarily allocating memory to my temporary nodes).
When I run the small dictionary with cat.txt, it ...
0
votes
2answers
34 views
In PSET5/ Speller - Unload Valgrind says Conditional jump or move depends on uninitialised value(s)
So my code passes all the Check50 tests apart from the memory one. I have been playing around with this for ages, but don't understand what the problem is. Here's what valgrind says.
And here's the ...
0
votes
1answer
30 views
My Code compiles but I am getting a leak “8,013,096 bytes in 143,091 blocks are still reachable in loss record 1 of 1”
I see that valgrind is saying that the leak is happening at malloc but I am not sure how to free it seeing where it is allocated (within loop). Please help.
'''
// Implements a dictionary's ...
0
votes
1answer
25 views
speller: Testing myself works but check50 says it's producing no output
I have tried testing my code normally with the provided dictionaries and texts, and it seems to work, producing the expected results in a reasonable amount of time. However, when I use check50, it ...
0
votes
1answer
21 views
Pset 5- Output is correct but still cant pass check50
I am currently working on Pset5, Speller. My output seems to be identical with cs50's solution (mine is simply way slower), but I still can't pass check50, it simply shows a blank window for my output....
0
votes
2answers
46 views
Segmentation Fault on Speller's Load function
bool load(const char *dictionary)
{
FILE *dict = fopen(dictionary, "r");
if (dict == NULL)
{
return false;
}
char word[LENGTH + 1];
while (fscanf(dict, "%s&...
0
votes
2answers
31 views
Problem freeing memory in Speller hash function
I have a problem to free the memory for the variable lowercaseword, I try to do it above the return statement with free(lowercaseword), but then the program stops working and I get errors on check50. ...
0
votes
1answer
21 views
cs50 pset5 functions check load assistance required
I have reached an impasse with regards to this exercise.
I believe that I have written the load function and it works.
I also believe that the hash function works
I think the size function returns a ...
0
votes
1answer
21 views
PSET5 Load function leaking memory
I'm having a problem with memory leak, when I use Valgrind it tells me that I have 512bytes of memory leaked, I know the problem is with load because of Valgrind and because my load functions is ...
0
votes
1answer
36 views
(Speller) Search Function returns each word given as false, And when i run Small Dictionary gives me Segmentation Fault
// Implements a dictionary's functionality
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#...
0
votes
1answer
34 views
Pset5 Speller Valgrind error trouble
Baby programmer over here. Before moving on to the (check) function, I wanted to make sure the (load) function was correct.
After performing Valgrind, I received the following errors. Up to this point,...
0
votes
1answer
34 views
“Could not unload” error in pset4 speller
I am solving speller pset5. In check50 my code is wrong. Don't know why. dictionary.c:// Implements a dictionary's functionality
#include <stdbool.h>
#include <strings.h>
#include <...
0
votes
1answer
46 views
Word array sometimes filled with weird values - Speller
My code looks like this: (ignore the comments; they're old)
// Implements a dictionary's functionality
#include <stdbool.h>
#include <string.h>
#include "dictionary.h"
#include &...
0
votes
1answer
19 views
The strcsecmp() function is not working as expected
I am currently trying to solve pset5, speller. I managed to write every funtion correctly except of the check() function.
This is the check() function I wrote so far:
// Returns true if word is in ...
0
votes
1answer
32 views
Hash Function in Speller - Use of Undeclared Identifier Error
I'm stuck on the speller assignment but it feels like the smallest thing to be stuck on....in my hash function I keep getting "use of undeclared identifier" for n and i. Usually if this ...
0
votes
1answer
29 views
Pset5: check returns hashtable pointers as NULL despite hashtable values printed correctly in load
My check function returns all hashtable indexes as NULL (I printed a known index of 124 and still returns NULL), despite all indexes printed correctly in load. I am not sure where exactly the problem ...
0
votes
1answer
31 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
1answer
39 views
Struggling with PSET5 Speller valgrind problems (& possibly more)
I've been working on PSET5 for weeks now on & off and I'm becoming really frustrated. I think I'm lacking some understanding of the malloc/free relationship, I'm not sure. Here's all of my code. ...
0
votes
1answer
47 views
pset5 speller check function: cursor pointer keeps being NULL
I finished writing the code and tried to run the program, but it returned all words as misspelled.
When I ran debug50 on the check function, it shows that the cursor pointer does not take the value of ...
0
votes
1answer
24 views
Trying to fix a segfault in unload , pset5, speller
So when I originally wrote my code for the dictionary.c, I forgot to create the header nodes for each 'bucket' in the hash table. It ran well when every first node of each linked list had a letter, ...
0
votes
0answers
18 views
trouble loading dictionary
my load function seems to only load two words and all words are coming back misspelled. I don't know if the problem is with my load function or the hash function. I've gone over the load function ...
0
votes
1answer
27 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
1answer
16 views
My load function is licking memory
the program complies properly but when i use valgrind shows am leaking memory when I open the file in the FILE *file = fopen(dictionary, "r");
bool load(const char *dictionary)
{
// TODO
...
0
votes
1answer
43 views
CS50 Speller Not Free of Memory Errors
When I run check50 on my code, valgrind says:
Conditional jump or move depends on uninitialised value(s): (file: dictionary.c, line: 34)
112 bytes in 2 blocks are still reachable in loss record 1 of 1:...
0
votes
2answers
43 views
Segmentation fault error in pset5
I did the speller and had some errors that I solved, but now I'm stuck and need help.
I debug the load and hash (I know it's not ideal, but it works:))
Now I'm receiving the Segmentation fault error ...
0
votes
1answer
47 views
pset5 speller check50 error - code doens`t handle max length (45char)
i get this error from check50 and i can t figure out why...:
:( handles max length (45-char) words
expected "MISSPELLED WOR...", not "MISSPELLED WOR..."
everything else is green (...
0
votes
1answer
29 views
speller - unload returns false …?
unload returns false and i am not sure why....
when i run Valgrind i get this:
HEAP SUMMARY:
==7885== in use at exit: 608 bytes in 2 blocks
==7885== total heap usage: 143,096 allocs, 143,094 ...
0
votes
1answer
45 views
pset5 speller load - i don`t get it
how do i check the logic of this ... i have not yet implemented the hash function ... can i check for errors without doing this or it is impossible to check without the hash function...?
// Loads ...
0
votes
1answer
37 views
Pset5 Speller Issues with check and unload functions
I have been stuck on this pset for over a week now. I have already checked other answers to similar questions here but none have been helpful to me. Testing through check50 as well as the debugger I ...
0
votes
1answer
36 views
cs50 speller code complies and run also successfully. but it not qualifying for big board
:) dictionary.c and dictionary.h exist
:) speller compiles
:( qualifies for Big Board
expected exit code 0, not 139
:| passes benchmarking
can't check until a frown turns upside down
how to fix this
*...
0
votes
0answers
19 views
Pset5: Problem with loading multiple words with the same hash number
I am having problems with loading multiple words with the same hash code. The hash function I chose, from what I can understand, takes the ascii codes of all of the words in the dictionary, and ...
0
votes
0answers
57 views
CS50 pset5 Speller - Code Does Not Compile Due to Issue with Hash Table/Load Function
I've been working on Speller for a little while now, but I've run into a roadblock. I finished my first draft of speller and have been clearing up errors until this point. Here's my dictionary.c so ...
0
votes
1answer
26 views
CS50 Pset 5 Speller Can't Handle Substrings
For some reason, when I run check50 cs50/problems/2020/x/speller, it says that my code can't handle substrings, but everything else works. My code recognizes that there are 2 words in the dictionary, ...