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

pset5:(speller) Check function does not correctly identify misspelled words

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

Segmentation fault - load() function

This is my code for load() function. When I am doing "./speller text" it is showing Segmentation fault. Please help. typedef struct node { char name[LENGTH+1]; struct node* next; }node; node*...
2
votes
2answers
1k views

pset5 copy.c confused in fread

in copy.c i am seeing some weird code in the part of iterating the scanline and pixels. Since we are passing "inptr" to the (fread) and telling it to work just once. How does the code makes sure that ...
13
votes
1answer
3k views

check50 returns unexpected end of input

I recently finished my code for pset5 recover.c. It compiles, and runs successfully and recovers all 50 pictures. But when I try check50, it gives Checking.............................................
1
vote
1answer
497 views

PSET5 Valgrind memory leak in load() and errors in many contexts

I'm trying to implement a trie for pset5. The program compiles, and appears to spit out the right output, except Valgrind seems to have a LOT of issues with it! First, there's the memory leak, which ...
10
votes
1answer
4k views

How to Update bfSize in resize?

In resize problem, we have to update the headers of image. Which attributes should be updated and how do i update bfSize attribute?
4
votes
1answer
3k views

What data structure do you use to store the buffer in recover?

What data structure do I use to store the 512B blocks in a buffer? Thinking about an array or ints? Or am I completely off?
3
votes
1answer
5k views

Cannot use make: “Nothing to be done for whodunit.c”

For pset5 I did as suggested and copied copy.c to a new file named whodunit.c. I've left everything the same but hopefully changed the red pixel values. When I go to compile using make I get this ...
2
votes
2answers
6k views

pset5 speller.c check

Hi I'm tackling CS50's pset5. I am trying to implement speller and I got stuck on check part. I implemented load via hashtables and whole dictionary loads up correctly,when I'm using smaller text ...
1
vote
1answer
274 views

Pset5 Speller Valgrind error

I got Pset5 Speller to work correctly but I am getting a Valgrind error as follows 568 bytes in 1 blocks are still reachable in loss record 1 of 1: (file: dictionary.c, line: 108) for all the words. ...
1
vote
1answer
633 views

Recover creates the pictures, able to view them, but listed as jpg? in ls and check50 fails

I checked the boards and couldn't find if anyone else had the same issue. For some reason, Recover runs 'seemingly' correctly when I ask it to and I see the pictures in the folder from "000.jpg" to "...
1
vote
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
46 views

PSET5/Speller - Valgrind error: conditional jump, relates to table[i] array, but I've already initialized that (or have I?)?

I posted something similar a couple of days ago but have made progress since then. Specifically I found a couple of posts answered by Cliff B indicating the problem users had was that they hadn't ...
0
votes
1answer
162 views

CS50 PSET5 Memory Leak

I have spent more than 30 hours on this problem set and I am still struggling. At first, my program compiled but did not run, due to a segmentation fault. I finally fixed it and everything works fine, ...
0
votes
1answer
82 views

Load code pset5, speller.c. Segmentation error

bool load(const char *dictionary) { FILE *dic=fopen(dictionary, "r"); node *hashtable[26]; int num=0; char word[LENGTH+1]; while(fscanf(dic,"%s", word)!=EOF) { node *new_node=malloc(sizeof(node)...
6
votes
1answer
75k views

How to fix the “conditional jump or move depends on uninitialized value” valgrind error?

Need help again. I've got my linked list working. It copies a list of words from a file into a linked list. Now I want to make a hash table so that all words starting with the letter 'A' go into a ...
5
votes
1answer
966 views

Pset5: Misunderstanding tries and method to assign letter to an array inside a struct

Before posting, I've searched a lot here and there on the Internet to find the answers to my questions myself and I did code something that eventually works. My issue is that I've re-rewrote some ...
9
votes
1answer
3k views

Surprise with GDB way of reading bfType BMP headers

Why if i check with the xxd an image eg. small.bmp the bfType is 0x424d and when you run copy in GDB the value of bf.bfType is 19778 and the program "copy" in line 55 check with 0x4d42. Is it reading ...
0
votes
1answer
2k views

How to make the check function faster?

It seems to be taking too much more time comparing to staff's implementation. The other 3 functions are average, though. dictionary.c: https://gist.github.com/9dcb901f2007d09ae1c9c4fa934f13df Mine: ...
0
votes
1answer
170 views

How do I use gdb on dictionary.c?

My speller.c works (finally), but the output is wrong. How do I step through dictionary.c with gdb? Typing "n" repeatedly on gdb speller gives each line of speller.c, but nothing in the called ...
0
votes
2answers
784 views

resize vertically doesn't work

First of all I know there are a lot of other questions like this but I have looked at all of them. They have helped a lot but I am still stuck. I can't see anything logically wrong with my code, but ...
0
votes
1answer
389 views

pset5 all words misspelled

I tried so many times and fixed somehow based on reply. This is a little embarrassing but I still cannot figure it out. There must be some problems in load and check. #include "dictionary.h" ...
4
votes
2answers
6k views

Conditional jump or move depends on uninitialised value(s)

I just finish debugging my code for pset5 dictionary.c, It's working correctly, It passed check50 too. Now the problem I am encountering is in valgrind my heap is all freed, But wherever in ...
2
votes
1answer
120 views

How do I make dictionary.c compile with strings.h?

There seems to be a useful function -- strcasecmp -- in the strings.h library (notably different from string.h). However, when I try to amend this to my header information (e.g., #include <strings....
2
votes
1answer
352 views

CS50 PSET5 Memory Leak (updated)

I had posted a question here two days ago regarding memory leak in problem set 5 and haven't had it resolved yet. Please refer to my question, available here: CS50 PSET5 Memory Leak (please note that ...
1
vote
1answer
2k views

Speller.c appears to be working but is case sensitive (can't recognize capitol letters)

I'm getting my spell checker to load and check. It appears to work (as far as I've tested thus far) except for I can't get it to be case insensitive. I've tried a couple of approaches, but in both ...
1
vote
1answer
2k views

resize: having header problems

My program compiles and everything, but when I try to open up the image it says the image has "bogus header files". I'm not sure what I'm doing wrong. Here's some of my code: // read infile's ...
1
vote
1answer
284 views

check50 has 2 TODO's in red for resize.c

When I run my implementation of resize.c in check50, there are two "TODO's" in red at the bottom of some sections. Does anyone know what this means? (My programs output is identical to the staff's ...
1
vote
1answer
309 views

pset5 unload double free or corruption

* Error in `/home/jharvard/Dropbox/pset5/speller': double free or corruption (top): 0x0804c698 * If I set unload to always return true, load/check work perfectly. Valgrind gives me a lot of invalid ...
1
vote
1answer
275 views

Unload function double free or corruption

so I've been battling through the fifth pset and this is where I can not find a proper way to continue. When I try to run it, it always aborts and gives this error: * Error in `./speller': double ...
1
vote
2answers
280 views

Problem in my unload function (double free or corruption)

so I have been straggling pset5 for some time and I end up getting double free or corruptionand don't now how to fix it. Here's my code : /* inside load() */ // some code if(head->children[b] == ...
1
vote
1answer
263 views

pset5 - possessives and substrings

I have posted this questions a few days ago, but none of us were getting anywhere. I thought maybe including my code for load as well as check might yield some new revelations. Anyway, here is the ...
1
vote
1answer
217 views

pset5 load function segfault do not show in gdb

I cannot figure what's wrong with the code, it gives me a segfault, but runs in valgrind and in gdb. So far, i only wrote the load function, so anything else is still empty. #include <stdbool....
0
votes
1answer
38 views

find the leak! pset5

I have run ./test which processes this function: bool unload(void) { //free up memory from linked list for (int i = 0; i < 26; i++) { if (hashtable[i] != NULL) { ...
0
votes
1answer
1k views

PSET5: Hash function returning collisions

Looking for advice on hash functions and strings. For PSET5, I decided to implement a trie but instead of storing [a - z] in each node, only storing [0 - 9]. For this to work, I hashed the words and ...
0
votes
1answer
156 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
1answer
241 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
105 views

Stuck on the unload() function. Possibly wrong logic used on load() and check() using tries

I am using tries to complete the spellcheck but I just can't keep up with the logic. I've implemented load() and check() as much as I could but I'm sure it has some logic flaw. The unload() function ...
0
votes
1answer
1k views

incompatible integer to pointer conversion returning 'int' from a function with result type 'struct node *' with custom create_node function

Clang returns an incompatible integer to pointer conversion returning 'int' from a function with result type 'struct node *' error when my create_node function checks whether the ptr malloc returns ...
0
votes
1answer
69 views

can I just return trav->is_word from check?

I've been struggling terribly w/speller. Most recently the check function. I'm troubled by how convoluted my code looks because I see it as indicative of convoluted logic. I most recently generated a ...
0
votes
2answers
375 views

Pset5 resize works but fails check50 TODO- bytes and headers match staff bmp file

I know others have had a similar problem and I have tried to find my error but I see no difference between my bmp file and the staff.bmp. Since reddit seems very quiet these days I am posting here ...
0
votes
2answers
140 views

PSet5 Unload(): *** Error in `./speller': double free or corruption (top): 0x0000000002bcb610 *** Aborted

I have been trying to solve this problem for about 3 weeks now...after multiple iterations I just cannot seem to find what I am doing wrong in the load or unload functions to trigger this error. Below ...
0
votes
1answer
69 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
82 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
142 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
372 views

Recover pset5 scope?

I'm almost there, but one more question about recover.. In my code, I open a file inside an if condition, but how do I acces that file later? It's getting out of scope and I'm getting use of ...
0
votes
2answers
304 views

Pset5 - Problem with hash table load(), malloc, and segmentation-fault

I am having problem with the load function. When I run: valgrind --leak-check=full ./speller texts/austinpowers.txt it gives me the following report (I am using the small dictionary to test my code) ...
0
votes
1answer
144 views

CS50 PSET5 Memory Leak (updated2)

I had posted two questions regarding memory leak in Problem Set 5, available at CS50 PSET5 Memory Leak and CS50 PSET5 Memory Leak (updated). I got amazing feedback from different people (and I ...
0
votes
1answer
82 views

Pset5 compile but report segmentation fault inside load

HELP!! I'm finally able to make my code compile without error. I know it won't guarantee it'll work, but at least I can move to the next step. :-) When I run the code it gives me segmentation fault in ...
0
votes
1answer
664 views

Resize.c fails the check “resizes 2x2-pixel BMP to 4x4 correctly when n is 2”

Check50 is failing my code and I am out of options to troubleshoot this. Any help from the community is greatly appreciated. I have compared different resizing factors for small.bmp and smiley.bmp ...