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
74 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
121 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
93 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 <stdbool.h> #include "dictionary.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include <...
0
votes
1answer
155 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
46 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
1answer
145 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
78 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
25 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
1answer
57 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
1answer
146 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
65 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
68 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
33 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
139 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 ...
1
vote
2answers
6k 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
59 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
77 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
98 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
38 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
57 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
2answers
102 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
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
55 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
97 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
88 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
101 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
39 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
25 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
1answer
122 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
79 views

I keep on getting a segmentation fault in pset5, please help

typedef struct node { char word[LENGTH + 1]; struct node *next; } node; // Number of buckets in hash table const unsigned int N = 100; //Size of dictionary int size_of_dic = 0; // 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
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
1answer
64 views

Failing miserably on check50 and valgring, even though all my answers match exactly the staffs' keys

I don't know why my code is falling on check50! It seems like it is blowing the time limit. Is it possible? I ran my program with many texts, and the results always match the staff's key. Can ...
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
12 views

My parameter isn't being recognized, although it's a constant

///Here's my load function bool load(const char *dictionary) ///Here's a later part of my program unsigned int size(void) { if (load(dictionary) == false) { return 0; } return ...
0
votes
1answer
31 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.
1
vote
1answer
312 views

My check function in speller isn't working

I have implemented everything else but this check function when I try to test it it seems like the the check function isn't working, because the no. of misspelled words is the same as the no. in text.....
0
votes
1answer
84 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
0answers
63 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
24 views

I don't get why the pointer to next in the node is “new” and not “head”, can someone please explain?

I'm practising using Linked Lists, and trying some exercises here: https://study.cs50.net/linked_lists Here's an exact copy-paste of the code found at the bottom: #include <assert.h> #...
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
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
1answer
515 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. ...

1
3 4
5
6 7
25