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
2answers
95 views

Speller, pset5. Help fix memory loss. How to fclose properly? How to close char *index = malloc(46)?

I have a problem here, if I fclose(dict_source) (comment where I place it) all code stop working (code stop find misspelled words), also if I try free(index) it's return free(): invalid pointer. Other ...
0
votes
1answer
93 views

pset5 - check50 fails at valgrind but valgrind directly seems to show no errors?

#include <stdbool.h> #include <cs50.h> #include <string.h> #include <strings.h> #include <ctype.h> #include <stdlib.h> #include "dictionary.h" const int ...
0
votes
1answer
114 views

Pset5 speller fail to check50 (update : cannot print the report of benchmark in check50)

=================================UPDATE=================================== Because one of the failed to spell-checking is case-insensitive of check50, I think maybe the problem is caused by my hash ...
0
votes
1answer
62 views

Pset 5 Speller: Identifying all words as misspelt

I was wondering whether anyone would be able to identify the issue with my code for Speller. I think that I should be nearly there but I'm struggling to work out why my code identifies every word as ...
0
votes
1answer
83 views

PSET5: Check is not working properly…i think

When I test my code...it counts most words as misspelled and only 1 or 2 words as being in dictionary..i presume the issue is in the check function...i do believe the load function works just fine as ...
0
votes
1answer
28 views

small memory leak in pset 5

My code is leaking just 276 bytes of memory in pset 5, and I am at a loss to understanding where it is. Using help50 and valgrind, I get the advice: Looks like your program leaked 276 bytes of ...
0
votes
1answer
466 views

Segmentation fault in Speller CS50

Similar to others, I have been getting a segmentation fault on Pset5, though my code compiles and valgrind doesn't flag any errors or leaks. I am not exactly sure what to look for with seg faults, so ...
0
votes
1answer
49 views

Help with pset5 'recover': incomplete jpgs

I´ve been working on recover for the past few days and I am having some trouble getting a working solution. The code below prints out 49 jpgs instead of 50, and they are all incomplete or very blurry. ...
0
votes
1answer
81 views

why pset5 works with small dictionary but with large dictionary gives munmap_chunk(): invalid pointer Aborted error?

I have been following all the instructions very carefully and have been able to come up with a code that looks like it should be doing all the steps needed in every function, I would say. When I ...
0
votes
1answer
350 views

pset5 speller unload function

I tried two methods but still, have a memory leak and also I didn't know how I know every step succeed or not. it supposes return true if free all memory and return false is not where I must write ...
0
votes
1answer
288 views

pset5 speller could not open text

load function looks good I think the error in speller.c when I wrote ./speller texts/lalaland.txt output: MISSPELLED WORDS Could not unload dictionaries/large. when wrote ./speller text output: Could ...
0
votes
1answer
39 views

Pset 5 Speller. I get segmentation fault. The problem seems to be in the load function, when creating a linked list

#include <stdbool.h> #include <stdlib.h> #include <string.h> #include "dictionary.h" #include <ctype.h> #include <stdio.h> int wcount = 0; // Represents a node in a hash ...
0
votes
1answer
235 views

Pset 5 Speller Linked List Nodes

I thought I got pointers but I don't fully understand a function that gets a new node for a linked list. I understand the theory behind Hash tables and chaining with linked lists but when it comes to ...
0
votes
2answers
163 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
1answer
55 views

pset4 speller unload trie leaking memory

I can't seem to figure out why my code is leaking memory, I think I have implemented recursion correctly, take a look at my unload code. EDIT : I tried running my file with large dictionary and using ...
0
votes
1answer
43 views

Pset4 speller segmentation fault in check functions when using larger files like holmes.txt

I updated my hash function to make the code faster, it makes a hash table and stores word with the same first three letters in one linked list, i.e words starting with aaa will go together, words ...
0
votes
1answer
32 views

Pset5 Trie Segmentation fault

Have been trying to debug this for days and eventually came down to the following problem: When running an example test(lalaland.txt) the misspelled words are fine up until the program abruptly stops(...
0
votes
1answer
190 views

valgrind in speller unload says I am using a variable without a value, when I assign it in the previous line

I just finished my pset5 and when I try to run valgrind with help50, it appears that Looks like you're trying to use a variable that might not have a value? Take a closer look at line 115 of ...
0
votes
1answer
86 views

Speller(hashtable) VALGRIND ERRORS!

i don't know or understand through val grind where and what i'm doing wrong. Except for memory errors my code outputs as correct in check50. my code // Implements a dictionary's functionality #...
0
votes
1answer
74 views

Speller(hashtable method), long delay in output, and check50 not working

I finished all the TODO functions and fixed all the errors, but the program takes 20-25 seconds to output anything, the dictionary load time is 4.3 seconds in the output, the total time is 4.6 seconds,...
0
votes
1answer
389 views

Failing last check on memory errors - “program is free of memory errors”

When I run check50 the code fails on the last check below: "valgrind tests failed; rerun check50 with --log added to end of command for more information." See https://cs50.me/checks/...
0
votes
1answer
123 views

Problem Set 4 Valgrind

I tried to implement Speller, but check 50 returns: :( program is free of memory errors valgrind tests failed; rerun check50 with --log added to end of command for more information. When I run ...
0
votes
1answer
288 views

PSET5 “Linker Command Failed with Exit Code 1”

I've been working on speller (implementing a hashtable) for quite a while now and I'm stuck...my code compiles but I'm assuming there's a run-time error. I'm not sure what to make of my error message, ...
0
votes
1answer
61 views

cs50 speller trie: (in c language) can't figure out what i'm doing wrong with load. Seems to work but seems non-existent in other functions

sorry if I am asking the question in a wrong way or my code is too messy I am knew here. My problem is that it looks like load works and the dictionary is loaded into the trie but check and unload ...
0
votes
1answer
44 views

Pset 5 speller - accessing node->next results causing problems with valgrind

As the title says, every time I access node->next and run valgrind, it says I have an 'invalid write size of 8'. When I run check50, I get all smileys except the last for the last check. I have tried ...
0
votes
1answer
331 views

Pset5 Speller returning one less word in text

So I have been at this problem for some time. I’m glad I have gotten as far as I have. I believe I just have a small step to go before I finish the problem set. (or maybe not). My trie seems to be ...
0
votes
1answer
145 views

Code runs fine until Check50 then it cannot load dictionary

Code runs as intended (other than some memory leaks that need to be fixed). But when I run check 50 my load function throws a "couldn't load file" error for whatever dictionary is being passed into ...
0
votes
1answer
49 views

Speller load() seemingly overwriting each word value

I think my load function is pretty close, but I cannot seem to get it to work properly, I built a function to read the data and I saw it's only storing one word in each bucket. Any ideas on what's ...
0
votes
1answer
447 views

Speller (pset 4 2019) - Can't fix memory leak in hashtable

I've been working on speller, and all my code does the job fine but I can't get rid of the memory leak valgrind is giving me. It seems to be something to do with my load function. I think it's my ...
0
votes
1answer
75 views

Pset5 load - Stuck in infinite nested while loop

I have been working on this problem set for some time. At the moment I am stuck at figuring out why the nested while loop is infinite despite of the fact that there is an fgetc() function that runs ...
0
votes
1answer
695 views

error: use of undeclared identifier 'word'

I've been having quite a few issues with Pset5 and I can't figure anything out. I've been playing around with the placement of 'char word[LENGTH+1]' but I always get an error: "use of undeclared ...
0
votes
1answer
13 views

Speller - Where to place struct

Speller pset: I am working on building a trie for the dictionary (load). In order to do so, I know I need to create the struct node. I thought that this was supposed to go in the dictionary.h file ...
0
votes
1answer
116 views

pset5 - Conditional jump or move depends on unintialized value

Valgrind seems to complain with my unload() function, in particular the cursor: bool unload(void) { node *cursor; for (int l = 0; l < 27; l++) { if (hashtable[l]) { ...
0
votes
1answer
30 views

Problem with the check function in pset5

I am trying to get speller to work. I have not started writing the unload() and size() functions yet. Speller can be compiled but when I run it, it yields the error "dictionary.c:39:13: runtime error: ...
0
votes
1answer
55 views

Memory leaks on unload

All tests pass except the valgrind check at the end. I am sure that my unload algorithm isn't correct, but I checked like 5 times, and I can't find logic flaw. I don't need solution, just a hint ...
0
votes
1answer
145 views

Memory leaks in Speller

My program passes all tests except the valgrind check. I tried to find the cause of errors, but valgrind is too 'obscure' for me yet, I don't know what to do. I guess some memory isn't freed, but I ...
0
votes
1answer
40 views

pset5 overall guidance

I unfortunately don't have a more specific title as I'm looking more for some overall guidance in pset5. I think I am very close to solving it, but some issues I am having are as listed below (hoping ...
0
votes
1answer
69 views

pset5 (trie) valgrind memory leak

I'm having trouble with the last step of pset5, valgrind. When I run it with the test text I get: Looks like you're trying to access 8 bytes of memory that isn't yours? Did you try to index into an ...
0
votes
1answer
155 views

pset5 “words in dictionary” is 0

I'm not having much luck troubleshooting my speller code. It returns the correct misspelled words and words in text, but words in dictionary returns as 0. I ran valgrind and it said there is a leak in ...
0
votes
1answer
53 views

PSet5: Segfault in unload

My code compiles, but when I run it it returns the following message and segfault. dictionary.c:183:9: runtime error: index 27 out of bounds for type 'struct node *[27]' dictionary.c:185:15: runtime ...
0
votes
1answer
244 views

56 Bytes of leaked memory in speller.c pset5

56 Byte memory leak - not sure where it is coming from. Valgrind points to the malloc'd space for nodnew in the load function - in my first version, I created the pointer nodenew and malloc'd the ...
0
votes
1answer
158 views

dictionary.c not iterating through the linked list, if the hash exists it always returns true

Trying to figure out a bug in my dictionary.c code. Please bear with me as I try to explain the bug. I've been using the debugger, and it seems that anytime there is a collision in my hash table, ...
0
votes
2answers
35 views

speller dictionary I compile and run the program. My problem is to free the memory. I even run the valgrind and my problem is on line 68

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

Style50 not working for pset5 speller

My code just works here for speller. I am receiving 4 out of 5 in style. A 5 over 5 will make me pass this pset by crossing 70% threshold. Can you Please spot errors in style? // Implements a ...
0
votes
1answer
148 views

Pset5 Speller : Check gives segmentation fault : Tries

I am not getting where the segmentation fault is happening. // Implements a dictionary's functionality #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <...
0
votes
1answer
49 views

More speller help: how to free 8mb of memory

Check50 passes on all counts except the valgrind test. This is the message I get: :( program is free of memory errors valgrind tests failed; rerun with --log for more information. I have just ...
0
votes
1answer
295 views

Please help with Speller: all words return misspelled

I've combed through my code for this pset and reviewed the walkthroughs and shorts countless times and am now resigned to admit I need help. Thanks to Peter, I'm no longer leaking any memory (yay!), ...
0
votes
1answer
334 views

Speller size function returning wrong dictionary size

I think I am almost finished with my speller program. It does print out misspelled words correctly, but it doesn't pass the check50, as the size function returns incorrect dictionary size. It fails ...
0
votes
1answer
385 views

pset5-speller-is this the correct way? (hash table implementation)

// Returns true if word is in dictionary else false bool check(const char *word) { int counter = 0; node *head = NULL; //node *...
0
votes
1answer
89 views

pset5 speller seems to work fine at first, but stops working halfway

I have been working on this error for couple days, but still cannot figure out what the problem is. The program compiles and finds the misspelled words in the beginning, but after printing out about 3/...

1
7 8
9
10 11
24