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.

250 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
108 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
1answer
26 views

Pset5 - Where am I leaking 1 block of memory?

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

PSET 5 SPELLER - segmentation fault

I keep getting a segmentation fault on my load function when using the debugger. Specifically, the line with "if(table[num]->next != NULL)" is what is causing it. I need some help, please....
0
votes
1answer
85 views

pset5 valgrind tests failed

I'm very close to completing pset5; all smiley faces except the Valgrind memory leak. I'm hoping someone can help find the problem. I am only leaking 112 bytes and have tried to fix the issue by ...
0
votes
1answer
47 views

PSET 5 My hash table doesn't seem to be storing correctly

When I load the dictionary, I add the words to the hash table, by calling the hash function to calculate the bucket ID, then add hash function to actually insert it into the list. Inside the addhash ...
0
votes
1answer
174 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
0answers
17 views

One block still reachable plus other advice

I am trying to do pset5 speller and am running into a lot of problems Can't figure out what the problem is here. https://pastebin.com/fBkFeDA9 Also saw that the hash function is giving out negative ...
0
votes
2answers
86 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
60 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
0answers
21 views

Help me with Pset5 filter

// Implements a dictionary's functionality include include "dictionary.h" include include include include define HASHTABLE_SIZE 1000 // Represents a node in a hash table typedef struct ...
0
votes
0answers
35 views

Help me with Pset 5 Speller

Help me Guys Where did i go wrong in my code // Implements a dictionary's functionality include include "dictionary.h" include include include include define HASHTABLE_SIZE 1000 // ...
0
votes
0answers
72 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
64 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
2answers
39 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
292 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
71 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
0answers
109 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
1answer
31 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
1answer
142 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 "...
0
votes
0answers
22 views

what can be rong with my check function? it returning handles substrings properly after checking

bool check(const char *word) { // TODO int exist = 0; int index = hash(word); for(node *temp = table[index]; temp != NULL; temp = temp->next) { if((strcasecmp(temp->word, word) == ...
0
votes
1answer
72 views

Check function Segmentation

I am struggling to find the problem in my check function. I have a segmentation fault that it's position varies every time I alter my code a bit. bool check(const char *word) { int index = hash(...
0
votes
0answers
41 views

Cant figure out where im going wrong with unload and check

My check function, when unload had a bunch of leaked memory returned every word as incorrect. However, now I tried to fix my memory leak and im getting a double free error upon trying to run the ...
0
votes
0answers
226 views

Pset5 : Speller

I'm wondering how I can solve pset5: Speller. I've been stuck on speller for about a week now. I've been looking for help, but they seem to be all using tries, and i'm using a hash table. Should I ...
0
votes
0answers
17 views

PSET 5: Speller segmantation fault

Hi everyone! I am currently trying to finish pset5, but I keep getting seg faults with speller. I am a begginer in programming, so I hope that I will be able to finish it soon! Thanks for your time ...
0
votes
0answers
32 views

Segmentation Fault in pset 5 load function (maybe)

I have looked at this for hours. I am pretty sure the segmentation fault that I get when I try to run it is from line 82 to line 97. I only think this because load never successfully prints the ...
0
votes
1answer
58 views

Speller - Program has memory errors, but Valgrind claims all heap blocks were freed

:( program is free of memory errors | pset5 Speller I have invalid reads at lines 148 and 153 of my code (commented out below): bool unload(void) { // CS50 for (int i = 0; i < 26; i++)...
0
votes
0answers
39 views

pset5 speller issue

#include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include "dictionary.h" #include "string.h" #include <cs50.h> #include <strings.h> typedef struct node { ...
0
votes
0answers
97 views

pset5 speller seems to be working but fails in check50 - here is my dictionary.c code. Could not figured out the problem :(

//Libs include include include include "dictionary.h" include include include int dwc; // Represents a node in a hash table typedef struct node { char word[LENGTH + 1]; struct ...
0
votes
1answer
53 views

Speller: valgrind giving me segmentation fault but I can't see what's wrong with my code

I implemented speller and valgrind gives me a segmentation fault, but I just can't find the bug in my code. Please help :( Thanks a lot in advance. #include <stdbool.h> #include <stdlib.h>...
0
votes
1answer
61 views

PSET 5 Speller Compiles, But Completely Wrong Output

I spent the last few hours trying to come up with a solution and trawled through questions on this forum but I still can't figure out why my check function is not working out properly. For some reason ...
0
votes
0answers
53 views

pset5 speller memory leak problem

This is my first post here, so if I'm doing something wrong that I'm unaware of, please correct me. Here's the thing. I've just finished my code for pset5 speller. After some tweaks and bug ...
0
votes
0answers
86 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. ...
0
votes
1answer
37 views

I am having a segmentation fault before my main code runs, but code will compile. pset 5 - speller

// Implements a dictionary's functionality #include "dictionary.h" // Represents a node in a hash table typedef struct node { char word[LENGTH + 1]; struct node *next; } node; // Number of ...
0
votes
0answers
30 views

Pset5 Speller: Testing Produces Different Results Between Check50 and Keys

I am getting different results when using check50 versus using diff -y [output.txt] keys/[text] to test my code. The difference is always in WORDS IN DICTIONARY and mine is always off by exactly +1 ...
0
votes
0answers
24 views

Pset5 - Segmentation fault (Load function) - Using a for loop to make all elements of table[i] = NULL

The following is my load function and I am having a segmentation fault when I run the executable code by typing for example when I type ./speller texts/aca.txt When I run debug50, it is pointing to ...
0
votes
0answers
41 views

Need help fixing memory leaks

I need help fixing the memory leaks on the code! I have already tried fixing them, but I have no clue how to do so. Here is the complete code: // Implements a dictionary's functionality #include &...
0
votes
2answers
23 views

freeing temporary node in functions

how to free the temporary pointer, one creates during the check function? valgrind shows error on that particular statement tried freeing it only when it has reached null, i.e., transverse over all ...
0
votes
1answer
30 views

Pset5 load problem: Dictionary cannot be loaded

I run my code and it cannot load the dictionary. I'm not sure if the problem is with my code or the file location. Anybody knows why? Thanks in advance.
0
votes
0answers
62 views

PSET 5 (speller): I don't know why I receive an inaccurate count for words in dictionary

unsigned int size(void) { int count = 0; for (int i = 0; i < N; i++) { for(node *temp = table[i]; temp != NULL; temp = temp->next) { count++; } } ...
0
votes
1answer
61 views

Pset5 Load function memory leak

Valgrind tells me I have a leak with malloc'ed node below. However, when I try to free it (free(n);) at the bottom of my code, outside the while loop, the program won't run (it doesn't pass check50 ...
0
votes
0answers
41 views

PSET 5 - Valgrind - Invalid read of 8 - Unload

So close to submission! - However, when I check using valgrind the ouptut is: ==22743== Invalid read of size 8 ==22743== at 0x40135C: unload (dictionary.c:123) ==22743== by 0x400E59: main (...
0
votes
0answers
37 views

Help on Pset5 Speller

bool load(const char *dictionary) { // Open dictionary FILE *dict = fopen(dictionary, "r"); if (dict == NULL) { printf("Could not read.\n"); return false; } ...
0
votes
1answer
95 views

pset5 - almost all words misspelled

I'm having trouble with the implementation of the PSET5 spell check code. I've looked through a lot of CS50 Stack Exchange posts, but haven't found any help. The problem is either in the check or in ...
0
votes
1answer
82 views

pset5- speller: first word and any word above 7 characters is not recognized

The 'speller' program considers any word with more than 7 characters as misspelled, even though that word is there in the dictionary. Same treatment is given to any word which comes first in the file, ...
0
votes
1answer
73 views

(PSET 5) Test for case-insensitivity fails

I used strcasecmp for comparing the words case-insensitively. However, check50 showed that I failed the test for case-insensitivity. I believe that my programme treated foO, fOo, Foo, fOO, FoO, FOo ...
0
votes
1answer
18 views

a:hover and a:active tags not editable in html/css

I'm trying to make a homepage as per the pset5, and want to change the color and decoration of hyperlinks. The a:link and a:visited tags were editable, but not the other two. Here's my code for ...
0
votes
1answer
77 views

Declaring a node (a struct pointer) from a function

I'm tackling load and decided to make a create_node function for allocating memory, NULLing all children and setting is_word as false. What I wrote is essentially the same as in this question struct ...
0
votes
1answer
28 views

Why do I get a sanitiser error when creating this node loop?

This is the loop node *root; root = malloc(sizeof(node)); for(node *ptr = root; counter < length_of_input ; ptr = ptr-> a_node) { if(counter != 0) { ...
0
votes
1answer
40 views

How Do I insert information into a trie?

I'm trying to insert true into the second branch of a node. #include <stdbool.h> #include <stdio.h> #include <stdlib.h> typedef struct node { bool correct; struct node *...
0
votes
1answer
48 views

pset5 speller IDE and check50 show different outputs even though theyare run with the same code

When I run my speller code, it works perfectly fine in the IDE. However, after seeing check50, the output appears to be the following Anyone knows why this happens and how to fix it?