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

pset5 cs50 does not handle basic words properly

Can you please help with the following issue with speller from pset5 in cs50: When I run the cs50 check, I get that it does not handle basic words properly, I am guessing, my check function is not ...
0
votes
1answer
57 views

Speller week 5 Segmentation fault

I can't understand where and what my error is I think it's because of "load", but I can't fix it it returns an error when checking :) dictionary.c, dictionary.h, and Makefile exist :) ...
0
votes
1answer
82 views

Segmentation fault! when i execute the program it suffer segmentation fault but when i run debug50 everything is fine!

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

Pset 5 Load Function

I'm having trouble with my load function... I had it working previously, but after changing some stuff and dealing with the check, I ran into this issue and can't seem to figure it out... Every time ...
0
votes
1answer
4k views

Conditional jump or move depends on uninitialized value

I've been puttering around with speller for a couple of weeks now. It now works, returns the correct spelled words and decently quickly, but it doesn't like the code for load. Here, Valgrind gives an ...
1
vote
1answer
190 views

Resizing small.bmp with n=4 gives an image with a black rectangle on the bottom left corner

When I try my resize program on small.bmp and enter 4 as n, it gives me a 12x12 picture that is all green, but instead of having the white little square in the middle it has a black rectangle on the ...
0
votes
1answer
1k views

Why won't speller load large dictionary in pset5?

In pset5, Speller won't load the large dictionary. Per the pset instructions, I seem not to have implemented my dictionary.c properly. Below are the beginning of my dictionary.c load section, and ...
0
votes
1answer
110 views

pset5 unload base case

I haven't written any code yet, although I've written pseudocode for this problem, and I keep coming back to the issue of base case. I built a trie and now want to recursively unload it. I think I've ...
0
votes
1answer
108 views

Pset 5 Dictionary TRIE Segfault

I know posting the while code is not cool, but I frankly can't figure out what is wrong anymore. I should have done this with something easier than trie-structure, but since it is close to done I'd ...
0
votes
1answer
134 views

i don`t know what is wrong with my unload function?

enter code here /** * Implements a dictionary's functionality. */ #include <stdbool.h> #include<cs50.h> #include <strings.h> #include <stdio.h> #include <...
0
votes
1answer
123 views

pset5 check-all misspelled?

I have the following code for check. I'm testing it against dictionaries/small and a test.txt and all words are coming back as misspelled? I don't understand why all words are coming back misspelled? ...
0
votes
1answer
287 views

Why i get wrong horizontal resize

I\m really stuck in the formula for horizontal resize.For my new padding if i enter 4 for (n) i get for my new padding answer 1, is that correct? fpos_t startline; for (int a = 0, biHeight = ...
1
vote
1answer
375 views

pset 5 resize.cdoes not resize properly. works visually for smiley.bmp but not for small.bmp

Theses are my observations so far: It can resize the smiley.bmp properly without distorting the image. What I'm not sure about is whether or not the contents of its headers are right. It can resize ...
0
votes
1answer
651 views

Not sure why resize.c isn't working

resize.c compiles and runs, but produces an image with a lot of black space. A fresh set of eyes on my code is welcome to see where I have gone wrong. I assume it has to do with padding but I can't ...
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
199 views

Running time of speller.c/pset5

I am stuck into this for long and seems like no way out. I have tried implementing speller.c/pset5 using hashtables and my code passes check50 but I get a total running time of 0.5 on an average ...
0
votes
1answer
9 views

Pset 5- Output is correct but still cant pass check50

I am currently working on Pset5, Speller. My output seems to be identical with cs50's solution (mine is simply way slower), but I still can't pass check50, it simply shows a blank window for my output....
0
votes
2answers
26 views

Segmentation Fault on Speller's Load function

bool load(const char *dictionary) { FILE *dict = fopen(dictionary, "r"); if (dict == NULL) { return false; } char word[LENGTH + 1]; while (fscanf(dict, "%s&...
0
votes
1answer
27 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
77 views

Help with seg fault in pset5 speller

My speller seg faults at the space following the first word in whatever input text I use. Here is the gdb output for austinpowers.txt with the segfault just after reading the word AUSTIN: 107 ...
0
votes
1answer
98 views

Segmentation fault..Please Help

can anyone have a look at my code, find the problem and suggest improvements. im getting segmentation fault after calling 'check' function. typedef struct trie { bool word; struct trie* link[27];...
0
votes
2answers
23 views

Problem freeing memory in Speller hash function

I have a problem to free the memory for the variable lowercaseword, I try to do it above the return statement with free(lowercaseword), but then the program stops working and I get errors on check50. ...
0
votes
1answer
55 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
151 views

CS50 pset5 unload trie segmentation fault

I am having problems with implementing unload. load works perfectly and I can use the check function. I have tried many ways of changing my code but it only creates an infinite loop and I have no idea ...
0
votes
1answer
132 views

Pset5 Unload will not compile

I am still stuck on pset5 speller.c. I am trying to implement unload via tries. I have tried several different codes which were not giving the correct output, but the last one I did could not even ...
0
votes
1answer
17 views

cs50 pset5 functions check load assistance required

I have reached an impasse with regards to this exercise. I believe that I have written the load function and it works. I also believe that the hash function works I think the size function returns a ...
0
votes
1answer
770 views

CS50 Speller Pset5 - Comparing succeeds, Check50 fails and Valgrind succeeds

Comparing output with ~cs50/pset5/speller texts/austinpowers.txt returns successfully and valgrind works. I don't know why Check50 gives an error. I would appreciate some help please. Check50 NOW ...
0
votes
1answer
35 views

Struggling with PSET5 Speller valgrind problems (& possibly more)

I've been working on PSET5 for weeks now on & off and I'm becoming really frustrated. I think I'm lacking some understanding of the malloc/free relationship, I'm not sure. Here's all of my code. ...
0
votes
1answer
69 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
22 views

(Speller) Search Function returns each word given as false, And when i run Small Dictionary gives me Segmentation Fault

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

PSET5 Load function leaking memory

I'm having a problem with memory leak, when I use Valgrind it tells me that I have 512bytes of memory leaked, I know the problem is with load because of Valgrind and because my load functions is ...
0
votes
1answer
366 views

How can I debug my load() function in Speller?

So I have code that I feel as though should be working, but I'm having trouble checking my work. I wrote a function that I think loops through my table, but it only displays half of the data seemingly....
0
votes
1answer
24 views

Pset5 Speller Valgrind error trouble

Baby programmer over here. Before moving on to the (check) function, I wanted to make sure the (load) function was correct. After performing Valgrind, I received the following errors. Up to this point,...
0
votes
1answer
94 views

Speller thoroughly modified yet still fails tests pset5

I have put many controls into the code, simplified the hash function, used gdb extensively, all which suggest the code works yet it still fails the tests, especially words like Still, Home, Video, ...
0
votes
1answer
39 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
42 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
42 views

How can I tell if I'm analyzing my Speller load() results correctly

As far as I can tell the code I have seems correct, though when I try to print out what my table contains, I get repeats of the same value. I can't tell if I am printing the data from my hashtable ...
0
votes
1answer
110 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
322 views

I'm really having a hard time with speller! Gives me a seg. fault. Please, help!

This is my code for load and valgrind points at line 127 as the reason for the seg. falut. Please, can someone point out to me why. Thanks.`/** *Loads dictionary into memory. Returns true if ...
0
votes
2answers
39 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
52 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
31 views

“Could not unload” error in pset4 speller

I am solving speller pset5. In check50 my code is wrong. Don't know why. dictionary.c:// Implements a dictionary's functionality #include <stdbool.h> #include <strings.h> #include <...
0
votes
2answers
52 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
37 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
39 views

Word array sometimes filled with weird values - Speller

My code looks like this: (ignore the comments; they're old) // Implements a dictionary's functionality #include <stdbool.h> #include <string.h> #include "dictionary.h" #include &...
0
votes
1answer
14 views

My load function is licking memory

the program complies properly but when i use valgrind shows am leaking memory when I open the file in the FILE *file = fopen(dictionary, "r"); bool load(const char *dictionary) { // TODO ...
0
votes
1answer
15 views

The strcsecmp() function is not working as expected

I am currently trying to solve pset5, speller. I managed to write every funtion correctly except of the check() function. This is the check() function I wrote so far: // Returns true if word is in ...
0
votes
1answer
29 views

CS50 Speller Not Free of Memory Errors

When I run check50 on my code, valgrind says: Conditional jump or move depends on uninitialised value(s): (file: dictionary.c, line: 34) 112 bytes in 2 blocks are still reachable in loss record 1 of 1:...
0
votes
1answer
57 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
26 views

speller - unload returns false …?

unload returns false and i am not sure why.... when i run Valgrind i get this: HEAP SUMMARY: ==7885== in use at exit: 608 bytes in 2 blocks ==7885== total heap usage: 143,096 allocs, 143,094 ...

1
2 3 4 5
24