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
3k views

Cannot figure out what is wrong with recover - “Improper call to JPEG library in state 201”

Does anyone know why I might be receiving this error in my recover program? I've used xxd to confirm that the first four bytes are correct and signal that each is a jpeg. However, I am still receiving ...
1
vote
2answers
177 views

Trouble incrementing the number in jpeg filenames

I've gotten recover to work... sort of. The problem is difficult to describe without posting my code, but here's an attempt: My program can find all the jpg signatures (in GDB, my jpeg-finding line ...
1
vote
1answer
49 views

pset 5 The dictionary pointer, why is it a char*?

Just wondering, why is the dictionary pointer passed into load a char* instead of a file pointer? Since the dictionaries to be loaded are files.
1
vote
1answer
316 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
2answers
1k views

how to check if just the load function is implemented correctly?

I've just started this pset and only implemented load. So how do I know if my load function actually loads the dictionary and there are words in the hashtable without implementing the other functions ...
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
246 views

what is happening in pset5 resize hacker edition?

I implemented the staff's solution to compress a bmp by a factor say 0.5 and compared the compressed version with the original bmp using xxd command. I expected it copy just half of rgb triples from ...
1
vote
1answer
38 views

strcopy(new_node -> word, word);

In Pset 5, the speller problem, we are told to use the following code: strcopy(new_node -> word, word); to copy the word from the dictionary into the newly create node, called new_node in this ...
1
vote
1answer
345 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&...
1
vote
1answer
1k views

PSET5-Speller: Unload? When is it “true”?

Im working on the unload function and I had fortunately written a "print" function that printed every member in the hash table. Writing this I was able to use it for the unload and size function. ...
1
vote
1answer
621 views

pset5, load function. Initializing elements in hashtable to null

This is my load function from dictionary.c. I'm trying to create a hashtable of linked lists with separate chaining. There are 26 elements corresponding to each letter in the alphabet. My questions ...
1
vote
1answer
141 views

CS50 pset5 Memory Leak (trie structure)

So I've written the functions for pset5 using a trie and it seems to work fine. It gives the same number of misspelled words etc. as the cs50 one, but it seems that there are some memory leak problems....
1
vote
1answer
184 views

PSET5: Why is my code working without fully implemented Unload function

My code is working fine and Check50 is also passing it. However I have not implemented Unload function and I am wondering why Valgrind or Check50 showing any error? All i did was changed return False ...
1
vote
2answers
283 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
1k views

why do I need dictionary.h?

I am not sure why I need dictionary.h for pset5. I feel like I can define the functions check, load, size, and unload in dictionary.c. dictionary.c is set up so I can define the functions in it ...
1
vote
2answers
83 views

I can't view dictionaries with gedit

I cannot find the dictionaries for pset5. When I type in: "cd ~cs50/pset5/dictionaries" (as suggested in a question from May 5, 2015) I get the following error: "bash: cd: /home/cs50/pset5/...
1
vote
1answer
400 views

my .bmp files are not opening up but rather showing the error unable to open the file

whenever i tries to open smiley.bmp and other .bmp format files i gets the error 'problem opening the file ' I have downloaded my pset5 again but still then i'm getting the same error. I also wanted ...
1
vote
1answer
201 views

Is my pset5 resize working or not?

When I try to run my ./resize 4 small.bmp large.bmp I get this: jharvard@appliance (~/Dropbox/pset5/bmp): ./resize 4 small.bmp large.bmp Could not open 4. Check50 seems to say that I have extraneous ...
1
vote
1answer
634 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
1answer
869 views

Pset 5 - Recover

Having problems with recover (pset5) now. This is what I'm doing: Opening File Until the end of file Reading 512 bytes to buffer Checking first 4 bytes of buffer to see if a jpg has just ...
1
vote
2answers
44 views

Valgrind issue on PSET5 - Edited

sorry that this is a repost of a deleted question. I made a mistake in reading the specifications and didn't realise I wasn't able to alter the function declarations in dictionary.c & .h. The ...
1
vote
1answer
228 views

pset5 Speller: No Correct Output

I have tried again and again different ideas but I simply can not get Speller to find the right misspelled words. I have no idea what I'm doing wrong. I keep changing things in various functions to ...
1
vote
1answer
39 views

Memory leak and erratic behavior with code

Right now, I have been stuck for a while on the speller problem of pset7, due to some erratic behavior of my code. On some versions of it, many words appeared to be misspelled, but not all of them; ...
1
vote
1answer
121 views

Segmentation Fault Pset5

I wanted to test speller to make sure the dictionary loaded into my trie correctly. However, I received dictionary.c:65:27: runtime error: member access within null pointer of type node' (aka '...
1
vote
1answer
2k views

Could not load dictionaries/large

Every time I try to run speller.c I get an output of: Could not open dictionary Could not load dictionaries/large I have a feeling that it is to do with the location of the dictionaries but I have ...
1
vote
1answer
279 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
66 views

Speller.c finds some words, but says that correct words are mispelled PSET 5 - Speller

After finishing writing my functions in dictionary.c, I have tried testing it out using austinpowers.txt, but the output is blatantly incorrect. (As seen in pastebin, 6259 words are incorrect.) Some ...
1
vote
1answer
79 views

Valgrind memory leak, WORDS MISSPELLED: 1 pset5

Looks like your program leaked 1,120 bytes of memory. Did you forget to free memory that you allocated via malloc? Take a closer look at line 48 of dictionary.c. Its weard because i am freeing the ...
1
vote
1answer
49 views

Pset5 - Some misspelled words not identified

I have completed the load() and check() function for pset5, however, I have been facing problems as some words are not identified as misspellings such as the words "org" and "int" which are not in the ...
1
vote
1answer
324 views

How does HEAD in linked list work?

I still can't figure out how HEAD in linked list works. What type of data is head? How can head be linked (connected) to the first note? That is what I have written, but still, don not know how to ...
1
vote
1answer
1k views

PSET5 speller (load) - fscanf function error

When I used the fscanf function in the while loop i get the error; "use of undeclared identifier "word". Heres my while loop: while(fscanf(fpt, "%s", word)!= EOF) So first I declared my "word" ...
1
vote
1answer
50 views

Pset 5 - Question on check(), diff, and check50 (and I found it interesting)

With the help of @Blauelf and @Yuri Laguardia, I finally made my code working (my previous question here). Then I diff my own results with the staff's, and found that my check() function seem to be ...
1
vote
1answer
49 views

PSET5 : Question about structs

Why if I declare following struct : typedef struct node { bool check; node* children[27]; } node; and now if I create a variable containing this struct : node* var; and now if I check the ...
1
vote
1answer
268 views

Help Understanding Calculate Function (PSET5)

I was wondering if someone could help clarify the calculate function on pset5 speller.c (I've copied it below). I'm mostly having difficulty understanding what "->" is exactly doing. Thanks! double ...
1
vote
1answer
299 views

pset5 Why can't I create the root node for my trie?

The only code I have added to the top of my dictionary.c is this #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include "dictionary.h" /** *...
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
34 views

Appending function failed

I tried to implement a function to append nodes to a linked list using the hints on cs50 study but all i get is (runtime error). Here's my code #include <stdio.h> #include <stdlib.h> #...
1
vote
1answer
161 views

pset5 tries “Segmentation fault”

My load function crashes my program. :( I use nodes similar to instruction video: // node of tries typedef struct node { bool wordEnd; struct node* next[27]; } node; // root of the tries ...
1
vote
1answer
934 views

what is wrong with my resize?

My resize program isn't working. I have narrowed it down to the padding, but cannot find what is incorrect. It resizes images that don't need padding perfectly (multiples of 4), and the header ...
1
vote
2answers
271 views

i'm able to recover the 49th image but does check50 says unable to recover the 49th image

I spent hours but still then i'm not able to understand that why does check50 does not recognize my 49th recovered image eventhough i have recovered that image and i can see that the image is of ...
1
vote
1answer
179 views

A question about padding

So in copy.c the formula for padding is: padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; which I don't quite understand. For example (to my understanding) if the image is 3x3 the padding ...
1
vote
2answers
654 views

check50 says “bmp.h” not found even though “bmp.h” is in jpg directory

Hello all I have a question about compiling what I've written for recover.c The compiler shows me this message when I try to compile recover: " expected an exit code of 0, not standard error of ...
1
vote
1answer
2k views

recover end of file detection

I'm having a lot of trouble with recover. I have written some code, just to get the basic structure. I was trying to iterate over the raw file until the end, printing when stumbled upon a jpeg. ...
1
vote
1answer
377 views

Recover.c Segmentation Fault

Pseudocode: declare counter declare filename[8] main Open input Declare buffer do read(512 bytes into buffer from input) while (not start of jpeg) do write filename open ...
1
vote
1answer
24 views

Speller - unload is giving me 1000000 errors in valgrind

so I don't know what I should do with my unload function to make it work properly? Because valgrind isn't happy at all and it's giving 1000000 errors (literally). The load function works perfectly (I ...
1
vote
2answers
34 views

PSET 5 SPELLER - Passing Valgrind but not Check50

I am very close to solving this, my code is returning 0 errors from Valgrind when I run that on its own, but its not passing the memory errors parameter in check50, so I'm very confused. Any help ...
1
vote
1answer
46 views

PSET 5 Load and Hash seg fault

I've update the code somewhat. Mostly fixing my hash function so it will run properly with non alphabetical words. Three hours into this though and I still can't seem to figure it out. I know now it ...
1
vote
1answer
37 views

PSET 5 Load Function woes

Back with more questions about my code. 1) fscanf: When using fscanf do we need to iterate through what it is writing to the buffer to check for the null signifier so we can jump in and strcpy that ...
1
vote
1answer
31 views

Pset 5 Output to file different from terminal output

I'm stuck on Speller... the code compiles and provides the same output as the staff solution when the output is redirected to a file, as instructed, to: $ ./speller texts/lalaland.txt > student.txt ...
1
vote
1answer
98 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 { ...

1
2
3 4 5
24