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
339 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
608 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 ...
12
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
485 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 ...
9
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
5k 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
265 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
632 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 "...
0
votes
1answer
161 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)...
0
votes
1answer
30 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
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; ...
6
votes
1answer
70k 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
965 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 ...
8
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
2answers
783 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
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
1answer
385 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
5k 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
348 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 ...
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....
1
vote
1answer
1k 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
268 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
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
2answers
278 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
215 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....
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
302 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
261 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 ...
0
votes
1answer
150 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
216 views

PSET5: memory leak

Mem. leaking. help. Only written load function but have the free function within load. Haven't fleshed out unload yet. Want to test that load works before fleshing out unload hence have included the ...
0
votes
2answers
374 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
801 views

recover.c only recovers 1 image

I'm having a problem with my code for recover.c because it recovers only 1 JPEG and that JPEG isn't a JPEG. It starts with 0x68 and 0x74. After going through the code with GDB, it seems as that on ...
0
votes
1answer
138 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
2answers
135 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

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
1answer
220 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
663 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 ...
0
votes
1answer
141 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
738 views

Pset5 trie problem with load: persisting segmentation fault

I read lot of questions and answers about the "load"segmentation errors in pset5 but I still experience some difficulties fixing it. I tried to make sure there are no garbage values by initializing ...
0
votes
2answers
298 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
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
371 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
300 views

Submitting pset5 for proper grading

On the advice of the following statement in the instructions for pset5: "You may add functions to dictionary.c or to files of your own creation so long as all of your code compiles via make." I ...
0
votes
1answer
289 views

pset5 resize segmentation fault?

I am getting a segmentation fault when I run this program, and am fairly sure that the problem is in the third for loop, where I try to copy the bytes from *pixel to *line, duplicating each byte '...
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 ...