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.

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

My code matches the outputs in the keys, but does not pass check50

The code is here: // Implements a dictionary's functionality #include <stdbool.h> #include "string.h" #include <strings.h> #include <ctype.h> #include <cs50.h> #...
0
votes
1answer
65 views

PSet5 Speller, passing test cases but not check50

I'm implementing the most basic form of the speller function, using 27 buckets for A-Z and ' (apostrophe) . My code works for the test cases (i.e. the generated results match those in keys/) but when ...
0
votes
1answer
178 views

PSET 5 Speller Failing free memory of errors final check

So i am so close to finally completing this present and i still have some final errors to go through. Valgrind is saying that it is still leaking memory for some reason and i cant find the reason why. ...
0
votes
1answer
131 views

PSet5, Speller, all correct but problem with Valgrind

I am so close to finally finishing Speller, however I'm running into an issue with Valgrind that I don't understand. I was under the impression that when I malloc a node for the dictionary table in ...
0
votes
1answer
38 views

Pset5 segmentation fault due to sprintf

// Loads dictionary into memory, returning true if successful else false bool load(const char *dictionary) { int i; for (i = 0; i < 5382; i++) { table[i] = NULL; } int ...
0
votes
2answers
91 views

strcpy not working with struct items

bool load(const char *dictionary) { char splitStrings[9999][45]; FILE* dict = fopen(dictionary, "r"); node* item = table[0]; int i = 0; for (i = 0; fscanf(dict, "%...
0
votes
1answer
23 views

dictionary is allways null

// Implements a dictionary's functionality #include <stdbool.h> #include <string.h> #include <stdio.h> #include <ctype.h> #include "dictionary.h" // Represents a ...
0
votes
1answer
108 views

pset5 speller, passes all Check50 requirements except the last one (Valgrind)

My code is now working fine but misses out on fully completing Check50 because of the last requirement. Running ~/pset5/speller/ $ help50 valgrind ./speller texts/cat.txt, it returns: ==6259== ...
0
votes
1answer
39 views

PSet5 Speller, Load Function, help50 Valgrind returns “==2480== Conditional jump or move depends on uninitialised value(s)” at the strcpy line

I've been working on Speller for a while now, but I've been stuck on this same problem. When testing my code by running ./speller texts/ANYOFTHETEXTS, it says I load 143092 words, but it also always ...
0
votes
1answer
26 views

pset5 speller everything works but the program won't end

okay so i have done everything correctly in terms of getting the right results i get a correct number of misspelled words and the time is low enough. i just can't get the program to end. val grind ...
0
votes
1answer
65 views

PSET5 speller memory leak and dictionary not unloaded

I have been looking at this for about 5 days now and I can´t find where I am leaking memory or if I have any problems with my code logic. Everything compiles and Valgrind output is below. I am ...
0
votes
1answer
58 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
1answer
56 views

Speller.c doesn't work

I've spent pretty much time trying to solve a speller and got really stuck, don't know what's wrong with my code. It compiles but check50 says it's totally incorrect. I would be grateful if you could ...
0
votes
1answer
36 views

PSET 5 segmentation fault on checker

I figured out that the problem is the checker. The output of this code is a segmentation fault. I think I followed everything on the walkthrough. Here is the result that I got: the result of the code. ...
0
votes
0answers
78 views

check50 keeps printing “Could not load basic/dict.” what might be the problem in the code?

// Implements a dictionary's functionality include include include include "dictionary.h" include include include // Number of buckets in hash table define N 120000 //maximum length of ...
0
votes
2answers
75 views

Valgrind errors: “invalid read of size 8” and “…uninitialised value” (pset5, speller)

I have basically finished the code, no memory leaking and tests work out fine. However, Valgrind is not happy: Conditional jump or move depends on uninitialised value(s): line 141 This is one of the ...
0
votes
1answer
61 views

PSET 5 Unload Segmentation Fault

I've been stuck on this problem set for a while now. Valgrind is telling me I have a problem in my unload function, which is "Conditional jump or move depends on uninitialised value(s)". I can't find ...
0
votes
2answers
40 views

Linked list, List isn't passing by reference?

I've really been struggling with PSET5 so I decided to take a step back and write a simple linked list program. My program take in an array of characters as a command line argument and stores each ...
0
votes
1answer
113 views

CS50 Pset5 error: conditional jump or move depends on uninitialised value(s)

valgrind is showing me an error that I have trouble understanding. The error is "conditional jump or move depends on uninitialised value(s)". Valgrind is directing me to line 125 of my code, which is ...
0
votes
2answers
159 views

PSET5 Speller - Memory error

This has by far been the most rage-inducing pset in the course. Down to my last check50 error now, failing the "program is free of memory errors" test. I've run it in Valgrind and it says there are ...
0
votes
1answer
76 views

cs50 Pset5 Valgrind Error

I'm just about to finish pset5 but I'm stumped on this valgrind error. Check50 tells me everything works well except that I am leaking memory. Valgrind tells me the memory leak is coming from line 44 ...
0
votes
1answer
63 views

PSET5 Speller - Just totally lost, code compiles but all check50 tests fail

I've been beating my head against a wall on this pset for 10 days now, watched all the videos, solved all the compiler errors, and just when I felt like I kind of understood this thing I ran the test ...
0
votes
1answer
261 views

speller works fine but can´t pass check 50

I've been working a few days in speller and I've managed to make it work exactly like the cs50 staff's (or at least it looks exactly) But check50 says everything is wrong except compiling: :) ...
0
votes
1answer
170 views

CS50 Speller Load function

I looked through my load function with debug50 and realised that each time the loop is iterated, the pointer temp always gets assigned the same value despite freeing it, how do Igo about resolving ...
0
votes
1answer
305 views

Need help: pset5 “Speller”

I am having a strange issue with the pset5. When I debug the file, it works fine, but when I check it through Check50, it throws several frowns at me. Need suggestions. Here is my code: #include <...
0
votes
1answer
74 views

almost there, but Valgrind reports an uninitialised value

Thanks in advance for helping out an old Dutchie! I am almost there, but valgrind insists i have an uninitialised value on in the While loop: while (cursor != NULL) VALGRIND tells me ==...
0
votes
1answer
200 views

PSet5 case-insensitive using strcasecmp

Tried iteration over strlen and random constant variable but unable to solve: :( spell-checking is case-insensitive expected "MISSPELLED WOR...", not "MISSPELLED WOR..." Here is my full code: //...
0
votes
1answer
74 views

pset5 speller load - check function it does compile but my words in dictionary output are not correct

the following function is my load - check functions. I believe one of two have the issue but not sure which one. Thanks for the help. My cs50 checks are like the following : WORDS MISSPELLED: ...
0
votes
1answer
102 views

pset5 speller “Could not load dictionaries/large”

I cannot figure out what I am missing. Program keeps returning "Could not load dictionaries/large" I have checked and tried different suggestions from similar questions but I do have the folder ...
0
votes
1answer
18 views

Pset5 Speller: Valgrind error with bool check

I solved every memory leak I had, but I'm having some issues with this one. What's a good method to free memory from node* checker in this case? bool check(const char *word) { node *checker = ...
0
votes
1answer
89 views

Valgrind shows memory error pset5

My code is // Implements a dictionary's functionality #include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <strings.h> #include <...
0
votes
2answers
39 views

PSET5 - Valgrind error - no enough bytes are being freed

I've been on this pset for some time now and everythin seems to be working except that there are some memory leaks and I really can't understand why. I've checked a lot of other people's codes but I ...
1
vote
0answers
43 views

Speller doesn't answer correctly

my code is // Implements a dictionary's functionality #include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <strings.h> #include "...
0
votes
1answer
47 views

Speller Load doesn't see certain words

My load function sometimes overlooks certain words in the dictionary. For example it jumps over the word "nodes" instead of loading it into the hash table. bool load(const char *dictionary) { // ...
0
votes
0answers
130 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 ...
1
vote
1answer
237 views

pset5 Speller: No Correct Output

I have tried again and again different ideas but I simply can not get Speller to find the right misspelled words. I have no idea what I'm doing wrong. I keep changing things in various functions to ...
0
votes
1answer
208 views

Valgrind says no leaks possible. However has lots of errors

My code passes check50 apart from the memory leak section. Valgrind shows no leaks are possible but lots of errors: ==21401== HEAP SUMMARY: ==21401== in use at exit: 0 bytes in 0 blocks ==21401== ...
0
votes
1answer
32 views

Speller Works on all .txt files, but FAILS Check50

My Speller function works on all the .txt files provided with the keys. I even made a .txt containing the large dictionary and all the words are spelled correctly. However, when I go to use Check50 ...
0
votes
2answers
113 views

Pset5 Memory leak in unload()

I've been working on speller for about two weeks now and I've finally got the programm to work, but valgrind cam up with a few memory errors. I've managed to solve most of them on my own, but the leak ...
0
votes
2answers
55 views

Memory issue (Valgrind “Still reachable”)

My code seems to pass all the Check50 tests except the one for memory as valgrind returns a "still reachable" error. Not sure what needs to be done, any help will be appreciated. Thanks! My Code #...
0
votes
1answer
168 views

Valgrind uninitialized values pset5

This is my solution for pset5's speller problem, which uploads a dictionary with a hash table and checks an inputed text to find misspelled words. My code works fine when I run, but valgrind says "...
1
vote
1answer
121 views

Speller (PSET5) has output that is exactly the same as the staff's solution, but check50 returns many errors. What's happening?

My speller program (part of pset5) works well and the output exactly matches that of the staff's solution. However, when I run my program through check50, I still get several errors per their script: ...
0
votes
1answer
68 views

Pset5 Speller: Valgrind issue - conditional jump etc

I think I have my speller working except for the below issue. I can't see any variable's I have not initialized properly. Valgrind points to my check function (the offending line is marked below): /...
0
votes
1answer
63 views

PSET5 check50 fail but same expected output from actual

I've seen a similar post about this but I couldn't really figure out why my code doesn't pass check50. It might be on the load function, but I'm not entirely sure. I already ran the code with the ...
0
votes
2answers
134 views

pset5 speller almost all words are misspelled

I've looked through everyone with the same problem, the common answer seems to be lower-case issues in the hash function or freeing pointers before you are actually done using them. I have tried ...
0
votes
1answer
114 views

CS50 PSET5 Speller Valgrind error: still reachable: 8,013,096 bytes in 143,091 blocks

I have got this Valgrind error for my code. I know that I have not freed the malloc of new_node but I still could not solve this problem after trying many different ways. Can anyone help:( // ...
0
votes
1answer
281 views

cs50 pset5 speller check function too slow

When I run my speller program, everything compiles fine and the results are accurate, but the check function seems to be way too slow (takes ~7seconds) compared to staff's version(~0.2 seconds) and so ...
0
votes
1answer
51 views

Pset5 Valgrind Error: Reachable Memory

I've been on the speller problem for a while and I don't understand where i'm going wrong. Any help would be much appreciated. I'm getting the following error from valgrind when i run it alongside --...
0
votes
2answers
64 views

load function in speller not working properly not seem to figure out the correct way to link hastable?

Implements a dictionary's functionality #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <strings.h> #...
0
votes
1answer
76 views

Hello! I am stuck on pset5 speller

When I compile my code it gives correct results, but doesn't pass check 50. Could please anyone help me to find a mistake, thank you. #include <stdio.h> #include <stdlib.h> #include <...

1 2 3
4
5
25