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,282
questions
0
votes
1
answer
30
views
Pset5 Speller - Weird Load Function Bug (Edited w/ Code)
bool load(const char *dictionary)
{
// TODO
FILE *fdict = fopen(dictionary, "r");
if (fdict == NULL)
{
return false;
}
// create container string to hold ...
0
votes
1
answer
52
views
Speller Segmentation Fault Even After Freeing Malloc'd Nodes
The following is my code and, subsequently, the message Valgrind returns when I run it on ./speller texts/lalaland.txt.
I explored similar issues previously posted on Stack exchange, and added lines ...
0
votes
1
answer
55
views
CS50 Speller works but check50 doesn't
My code seems to work fine with all text files.
When I look at the errors it doesn't even show actual output, why could that be?
https://submit.cs50.io/check50/e963f4484de14f0b73f8fca9a5e9431556cb649a
...
0
votes
1
answer
56
views
PSet5 Speller: Are we hashing the words in the dictionary into a hash table or the words of the text?
I've completed the first function of the Problem set, where I've sorted every word in the dictionary into a trie, but I don't know if I was supposed to do that in the hash function, and something else ...
0
votes
1
answer
51
views
Everything is correct in my Check50 but in program I have other ERRORS - PSET05 Speller
I hope you're doing well and I also hope you might help me. When I run my CHECK50 in my speller program. Everything is correct all green, but when I run my program or valgrind I have some errors. And ...
0
votes
1
answer
2k
views
check50 error expected exit code 0, not 1
I was following python programming course and with the unit test chapter I updated the main file and the test files as described in this problem set page. Now I'm sure that my tests are running fine ...
0
votes
1
answer
169
views
Pset5 Speller - Valgrind issue
this one was tough. But in the end my code compiles fine and has no memory leaks, the hash function isn't very good but it works. Yet I still get an error message that I just don't understand. First, ...
0
votes
1
answer
50
views
pset5 speller load and hash functions
Whenever I run speller.c it appears that none of the words are getting loaded into the dictionary as the output looks like this:
MISSPELLED WORDS
A
cat
is
not
a
caterpillar
WORDS MISSPELLED: 6
...
0
votes
1
answer
34
views
PSET 5 Speller Valgrind Memory
My code is functional according to check50 but I'm still leaking bad memory. Based on amount of memory lost, I'm guessing something to close up in LOAD, but could be UNLOAD as well. First thoughts are ...
0
votes
1
answer
78
views
PSET5 - Speller - Valgrind returns memory leak
After many trials, I am currently stuck in this Pset. The full code that I have is as follows:
// Implements a dictionary's functionality
#include <ctype.h>
#include <stdbool.h>
#include &...
0
votes
1
answer
46
views
PS5 - Speller - Unload function
I have been going through the Pset5 (Speller) and I am currently stuck. Right now, I am just trying to have a functional code, so I am not worried about how optmized my functions (specially the Hash ...
0
votes
1
answer
40
views
pset 5 speller, turning frowns upside down
I thought i had wrote a correct programme for speller, check 50 says that my code compiles but that is all it does! I have been running my programme and combing through each function and I still can't ...
0
votes
1
answer
31
views
CS50 PSET 5: Returning 0 words in large dictionaries only
I've been trying to figure this out for a while now. I'm doing PSET 5 and all my dictionary words in large texts return 0, though when I've tried the small dictionary, it returns the words fine there. ...
0
votes
1
answer
132
views
Speller works for everything but one letter words
When I run my speller program it works on everything but one letter words. I have been trying to figure this problem for a long time. I think it is a problem with either my hash or check functions. ...
0
votes
1
answer
50
views
Speller outputs all words as misspelled
I currently am doing the Week 5 Speller project. My code outputs all words as misspelled. I think it has to do with the load() function, but I am not sure if or why it is doing that. I don't think ...
0
votes
1
answer
42
views
segmentation fault with node pointers on speller
I know which line has the segmentation fault ,
if (table[hashn]->next == NULL)
In this case hashn is 0 so its not exceeding the array
Any ideas why its happening?
0
votes
1
answer
78
views
PSET5 - SPELLER - Check50 only works locally
I am trying to run check50 on my version of speller. I worked for so long on this code. It was a battle every step of the way to get it to finally run. I finally seemingly got it today.
My code works ...
0
votes
1
answer
21
views
pset5 speller different unload algorithms
I just finished pset5 but I had a question about why a (what i think is) recursive method doesnt work but the one i went with does.
if you skip and look in unload youll see a "destroy" ...
0
votes
1
answer
59
views
PSET5 - 3 conceptual questions (debug not needed)
Question 1 (hash) – is it even remotely possible to reverse engineer the hash function when given lots of output?
For example if the underlying hash function is something simple like tolower(word[0]) %...
0
votes
1
answer
38
views
PSET5 unload error
bool unload(void)
{
// TODO
int i = 0;
for (i = 0; i < N; i++)
{
node *cursor = table[i];
if (cursor != NULL)
{
node *tmp = cursor;
...
0
votes
1
answer
2k
views
CS50 Pset5 Help
it's my first time on here after a long time of following conversations and seeking help. In Pset5 Speller (CS50 2022), I have a weird situation. My code for dictionary.c works when I use the basic ...
0
votes
2
answers
349
views
speller seg fault
I have been on this for literal days, there is always a seg fault no matter what i do
things i have tried:
debug 50: MULTIPLE TIMES, i fix the errors i find but end up with another one soon after, ...
0
votes
1
answer
31
views
I write all the function but the actual misspelled words are much greater than the expected misspelled value, not working well with substrings
// Implements a dictionary's functionality
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <string.h>
...
0
votes
1
answer
60
views
PSet5 - Dictionary loading only one word
I've been banging my head for the last few hours as to why my dictionary function only saves one word from the whole dictionary. Even though debug50 and printf shows different hashes for different ...
0
votes
1
answer
158
views
CS50 pset5 Speller: double free or corruption
I get double free or corruption (fasttop)\n Aborted when I run my code. Somehow, only small dictionary can handle up to around 50 words perfectly but sometimes it can only handle 10 words; other than ...
0
votes
1
answer
117
views
Pset 5 speller: segmentation fault for large dictionary
I can't figure out what I am doing wrong, have gone through many questions and walkthroughs of this problem and it still looks like it should be correct. It obviously is not! With a small and medium ...
0
votes
1
answer
32
views
I have no idea why my speller in pset5 is giving the wrong amount of misspelled words
I am not sure where my mistake is, I keep getting too many misspelled words.
This is the link to check 50 I run on the code:
https://submit.cs50.io/check50/ce552ed87b7d99ac966d9ba7a897bda34bf0a794
// ...
0
votes
1
answer
60
views
pset5 speller Hash table not appearing in the debug50 stack/heap
This question is related with this other question of mine, in which I am trying to complete pset5: speller.
I took Cliff's advice, and additionally executed the debug50 on my code. Since the original ...
0
votes
1
answer
72
views
pset5 speller memory errors with valgrind
i've been working in pset5 and cannot make it work. I've read some similar questions and made some improvements to my code, but still can't figure what is wrong. Any tips are welcomed!
Here is my code:...
0
votes
1
answer
211
views
Speller 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 ...
0
votes
1
answer
40
views
Speller still isn't running correctly
I rectified the earlier error in my code (putting dictionary within inverted commas). I also corrected my error in unload where the function would always return false instead of true. However, I ...
0
votes
1
answer
217
views
pset5 - speller "double free detected" when I run check 50 but program does nothing during self tests
I am currently doing Speller. I have written all the functions and the program compiles but during self testing it is printing "misspelled words" and stays stuck at a blinking cursor. It ...
0
votes
1
answer
39
views
pset5 unload + valgrind
I tried to solve problem with memory usage but did not figure out where is the problem.
Dictionary unloads successfully but still issue with memory access exists.
I think that problem with ...
0
votes
1
answer
47
views
Getting a segmentation fault on cs50's speller (pset5)
I would love a bit of help on cs50's pset5 speller. The program does compile. However, when I run valgrind ./speller texts/cat.txt I get a segmentation fault . I think I am overlooking something but I ...
0
votes
1
answer
57
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
113
views
Problem Set 5 - Segmentation Fault
I am trying to overcome the segmentation fault on the following code, and I couldn't manage to solve the error. Segmentation fault occurs in the load() function, and after hours of debugging, I couldn'...
0
votes
1
answer
27
views
Unload function pset5
I've completed the pset5 and got all the check50 marks correct, except the valgrind one. What is weird is that Valgrind also say that i've freed everything correctly. Here is the error message that I ...
0
votes
1
answer
36
views
70-90 Extra Misspellings - Any ideas?
I did ask this on Ed Forums so my apologies if you're sick of seeing it - but I'm still so stuck!!!
I get almost the right number of misspelled words on whatever text I use but it's off by the first ...
0
votes
1
answer
302
views
Lab5 free_family function
I have created the below function to free memory allocated by the create_family.
// Free `p` and all ancestors of `p`.
void free_family(person *p)
{
// TODO: Handle base case
if(p == NULL)
...
0
votes
1
answer
99
views
Why are check50 and valgrind telling different things?
When I run
help50 valgrind ./speller texts/lalaland/txt
it returns
==1123==
==1123== HEAP SUMMARY:
==1123== in use at exit: 472 bytes in 1 blocks
==1123== total heap usage: 143,096 allocs, 143,...
0
votes
1
answer
297
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 ...
0
votes
1
answer
61
views
Check function pset5 speller
I've been stuck on this for hours, please help.
bool check(const char *word)
{
char check_buffer[LENGTH + 1];
for(int i = 0; i < strlen(word); i++)
{
check_buffer[i] = word[i];
...
0
votes
1
answer
184
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
1
answer
539
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
1
answer
58
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
1
answer
34
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 ...
0
votes
1
answer
80
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
1
answer
121
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
1
answer
26
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
1
answer
26
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 ...