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
1
vote
1answer
84 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
57 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
52 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
83 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
92 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
189 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
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
45 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
58 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
69 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 <...
0
votes
1answer
67 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
1answer
91 views

i keep on getting segmentation fault in pset5

// Returns true if word is in dictionary else false bool check(const char *word) { //change letters to lowercase int length = strlen(word); char copy[length + 1]; for (int i = 0; i < length;...
0
votes
1answer
78 views

Getting a segmentation fault when i try to run pset5 speller and i'm not sure what's the problem. Appreciate it if someone can explain. thanks!

// Implements a dictionary's functionality include include "dictionary.h" include include include include // Represents a node in a hash table typedef struct node { char word[LENGTH + ...
0
votes
1answer
126 views

Pset 5 Speller valgrind error

I am trying to fix the last error in my code pointed out by check 50. I think the problem is in my unload but can't say for sure. Here's my code. I know I have some basic functionalities wrong but ...
0
votes
1answer
22 views

Pset5 Seg fault speller

I´ve been stuck in pset5 for a little while. I was wondering if someone would be able to take a loot at it? Fow now all my hash function does is look at the first letter of a word. I will of course ...
1
vote
1answer
45 views

Pset5 Speller — Conditional jump or move depends on uninitialised value(s); Uninitialised value was created by a stack allocation;

My code is able to pass all the tests in check50 except the valgrind one. Here is the error when I run the valgrind. Could someone help me, please? // Implements a dictionary's functionality #...
0
votes
0answers
220 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
1answer
100 views

PSET 5 - Speller : Cannot handle apostrophes and sub-strings

I have problem making my code handle apostrophes and sub-strings. Been stuck on it for 3 hours now. I am using my own implementation of hash. Here is the code: // Implements a dictionary's ...
0
votes
1answer
27 views

Segmentation Fault in pset5 with the Table Variable

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
63 views

CS50 pset5 program is free of memory errors valgrind tests failed;

I'm just minutes away from solving my problem in pset5. But I'm getting the following error from valgrind. ==12523== HEAP SUMMARY: ==12523== in use at exit: 0 bytes in 0 blocks ==12523== total ...
0
votes
1answer
24 views

PSET5 Unload() recursive sub-function causes 112 bytes to leak - why?

I've already fixed this issue playing around with my code, but I cannot seem to understand why this (former) version of my recursive function leaks 112 bytes (2 nodes). Can anyone please help me ...
0
votes
1answer
53 views

SEGFAULT in pset5 speller

I'm working on pset5 2020 speller. I have managed to get my code to compile but no matter how small the input data sets are I suffer a segmentation fault. I've run valgrind and there only seems to be ...
0
votes
0answers
16 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
31 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
51 views

CS50 Pset 5 speller valgrind error

I am currently trying to master speller but getting an error in one specific line when I run valgrind. It mentions this line: n ->next = table[index]; I have no idea why. It says invalid read of ...
0
votes
0answers
78 views

HI. I'm on pset5 speller mostly done but having valgrid problem. Don't understand why im geting it..Well i do understand what it says

[![enter image description here][2]][2] [2]: https://i.stack.imgur.com/yS0vD.png// Implements a dictionary's functionality include include include include include include include ...
0
votes
1answer
114 views

SPELLER(pset5), output of misspelled words is more than actual

There are two problems with the code: WORDS MISSPELLED are around five time normal. It is showing 5440 misspelled words while ideally there are around 900 such words(staff's solution). In the bool ...
0
votes
1answer
59 views

CHECK50 ERRORS IN SPELLER PSET

Here is my code for the pset I am getting 2 errors after check50. I am not able to get hold of any loopholes in the code. Kindly help! 1) :( handles max length (45-char) words expected "MISSPELLED ...
0
votes
2answers
58 views

CS50 Speller questions about how to move forward

I have a few questions about speller, both about how the program operates and how I should begin the start debugging and testing a program of this complexity. My first question involves why you only ...
0
votes
1answer
30 views

speller giving error on valgrind, using 4 bytes of memory that isn't yours…indexing an array out of bounds

I think the problem with is the load() function, here is my code: bool load(const char *dictionary) { char *s = malloc(LENGTH + 1); FILE *f = fopen(dictionary, "r"); if (f == NULL) { return false;...
0
votes
1answer
113 views

PSET5 - Speller - Doesn't display anything past MISSPELLED WORDS

I've been debugging for quite a while now and can't seem to figure out the solution to this problem. When I use the large or small dictionary on any of the texts, the program becomes stuck at ...
0
votes
0answers
62 views

pset5 speller - struggling to free memory (valgrind error)

My code: #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <ctype.h> #include <cs50.h> #include "...
0
votes
2answers
5k views

PSET5 Speller hash function

I have been working on the speller problem in pset5 for a while now, and I am not able to figure out the problem in my hash function: unsigned int hash(const char* word) { int M = 1000000001; ...
0
votes
1answer
44 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
1answer
50 views

pset5 Speller Valgrind conditional jump or move depends on uninitialized values

Sorry for asking about a valgrind-reported error that has been asked many times. I've read through many of the questions and responses, but I could not find an answer that applies to my problem. The ...
0
votes
0answers
96 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
36 views

Confused with Memory Leak in pset5 Even Though the Problem is Fixed. What was wrong with my size function?

Thank you in advance for taking a look at my code. I have been getting this error below: ==4734== 8,011,640 bytes in 143,065 blocks are indirectly lost in loss record 1 of 2 ==4734== at ...
0
votes
1answer
46 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
0answers
18 views

pset5 speller fails substring test

I've run my code through check50 and it passed all the test except the substring test. Does anybody know what might be wrong with this code? // Implements a dictionary's functionality #include <...
0
votes
2answers
84 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
59 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
48 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
1answer
78 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
0answers
79 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. ...
1
vote
1answer
89 views

pset5 /home/ubuntu/pset5/speller/speller.c:144: undefined reference to `size' By “undefined reference,”

// Implements a dictionary's functionality include include include include include include include include "dictionary.h" const int HASHTABLE_SIZE = 65536; typedef struct node { ...
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
85 views

Pset 5 - Error with freeing up memory - Use of uninitialised value of size 8

I am working on Pset5 and the only issue I am having is regarding the requirement for freeing up memory. Based on the output received from Valgrind, it looks like there is no issue with the memory ...

1 2 3
4
5
24