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.

253 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
1answer
96 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
0answers
248 views

pset5 check function skips some misspellings

I've ran the speller with the Austin Powers.txt, as so as i've ran the staff's solution. Mine speller catch's most of misspellings, but... Some small strings that are misspelled in the txt don't get ...
0
votes
0answers
100 views

pset5 load function mallocs more new then i expected, am i building the trie wrong?

With the answer and tips from Cliff B i've managed to stop segfaults and loosing data in the memory, but still unsure about trie implementation. Here's the current code: bool load(const char* ...
0
votes
1answer
341 views

dictionary check50 returns \ expected output, not standard error of “/opt/sandbox50/bin/run.sh: line 31: 102…”

My dictionary implementation appears to work as my program's output matches the staff exactly. Check50 is giving me the error below for every check starting with handles most basic words \ ...
0
votes
1answer
602 views

pset 5 dictionary problems

I am having problems with pset 5. Honestly so far I have never had such a huge problems with a pset. I watched every video, read many questions and answers on stack exchange and wrote some code, which ...
0
votes
1answer
604 views

pset5 load speller.c, seg fault with gdb

Changing this question to be specific. My load function seems to run past the end of the cs50 small dictionary to give a segmentation fault after it works for cat and caterpillar. I can see that cat ...
0
votes
1answer
108 views

pset5 Aborted (core Dumped)

I have been trying to debug this for over 2 days now. Can't seem to locate the reason why there's a segmentation fault. Running this returns a bunch of misspelled words plus an error message - ...
0
votes
0answers
135 views

speller.c can't load large but can load test dictionaries

I know this is a commonly encountered issue with PSET5 and I have trawled all of the answers however none have helped me. My code passes check50 and valgrind result is that there are no leaks. Speller....
0
votes
1answer
141 views

Segfault in check

I just moved on to pset5 and am finding a little difficulty. I believe I have implemented the correct code for dictionary.c but having searched through, I am getting a set fault during check. ...
0
votes
0answers
159 views

pset5 load/check: seem to be inadvertently freeing my hashtable

I think I've implemented load in a (mostly) correct way. For the most part it seems to be sorting and loading into the hashtable correctly but I'm not sure. The problem I'm running into is that I ...
0
votes
1answer
319 views

pset5 speller doesn't handle possesive and substrings properly

I got the following error while checking my pset5. :( handles possessives properly \ expected output, but not "\nMISSPELLED WORDS\n\n\nWORDS MISSPELLE..." :( handles substrings properly \ ...
0
votes
0answers
40 views

Strcopy pset5 segfault

I get this seg fault in the strcpy line when I debug with gdb. int wordlen = strlen(word)+1; char worda[wordlen]; strcpy(worda,word); I tried with char* but even then it wasnt working. Full code ...
0
votes
0answers
61 views

speller isn't running and I don't know if stuck or taking forever to even shoot error!

it's taking forever and I have no clue if there's a logic fail since I have run my own local program using tries to implement check using a few user entered words and then looking for the word which ...
0
votes
2answers
56 views

Exiting nested loops

I started off pset5 with a really simple hash function, where words are indexed according to their first letter, so a would be 0, b = 1 etc. Then I insert a piece of code into the load function, which ...
0
votes
1answer
447 views

Pset5, speller 'could not open text'

So I wrote my load function and everything looks good, so I had it return true so I could move on and test other parts of the program. My problem is that speller.c won't load my text. I made a custom ...
0
votes
1answer
272 views

pset5 Speller Unload Method, not sure where Im going wrong

I'm having issues with Unload at the moment, I am getting Seg error. I am moving tho the code with GDB and error occurs on a Null check i am doing in a while Loop. I am basically moving my transit ...
0
votes
2answers
393 views

pset5 valgrind not happy with load (also, using malloc vs calloc on trie)

First, valgrind flags the file pointer at the fopen call, and also the malloc call to the root pointer. It designates both still reachable in loss record. Second, since for pset5 I check for an end ...
0
votes
0answers
55 views

pset 5 what am i missing

Im having trouble with the syntax and language for pset5, its driving me nutz. Say I have the word BAT:- OK so I have a root node. I check the root node to see if index 1 ( position 2 for the letter ...
0
votes
0answers
358 views

PSET5 Speller: trouble with mispellings and tolower()

I am very close to getting my dictionary to word correctly, but I am having a small hiccup in my check function. In order to compare the word given in the check function to the dictionary, I first ...
0
votes
1answer
722 views

pset5 trie load function killed with large dictionary

This has been bugging me for weeks. The program seems to run OK with small dictionaries, but gets killed with medium size - after around 95,000 words - it varies. LETTERS is set to 27. Any help would ...
0
votes
1answer
102 views

where can i get ppt of Zamyla's explanation in pset5

I didn't find anywhere to get that, I just want to get the ppt of zamyla's ppt in pset5, it help me to walkthrough the problems.
0
votes
0answers
91 views

pset5 running staff implementation problem

recently i have taken a break from cs50, life got in the way, so I am sure I am missing something really simple......problem is running the staff solution for pset5. I typed in the command as per the ...
0
votes
1answer
96 views

End of file not found, why?

Help! i'm completely stuck is this code. After using a lot of gdb, i found out that when the end of file is reached the for loop (for(letter = fgetc(inptr); letter != '\n'; letter =fgetc(inptr)) //...
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
867 views

Conditional jump or moves depends on uninitialized values

I am getting the following valerind error. ==9649== Conditional jump or move depends on uninitialised value(s) ==9649== at 0x80493AD: check (dictionary.c:152) ==9649== by 0x8048A6D: main (...
0
votes
0answers
138 views

pset5. dictionary lost

In speller.c we call the function to load the dictionary into memory: bool loaded = load(dictionary); where the declaration of the function is: bool load(const char* dictionary); My load( ) ...
0
votes
2answers
111 views

About Spanish and PSET 4

I notice that CS50 is doing a really effort to make the course more accesible to everyone, and you can see this below the videos is a lot subtitles links in many languages. So, in PSET 4 there is a ...
0
votes
0answers
65 views

compiling errors

I'm dealing with pset5 (speller.c), and I chose trie to run the program. when I compiled it, it said: dictionary.c:25:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int] root ...
0
votes
0answers
330 views

Initially running speller using the staffs dictionary

When trying to run ./speller, I ran ./speller text to see it in action. I received the error: Could not load /home/cs50/pset5/dictionaries/large. I went to /home/cs50/pset5/dictionaries, and the ...
0
votes
2answers
278 views

mispellings load won't open file

It took me about a week to figure out that the files for what was formerly pset6 had been moved to the pset5 folder, and that's why my code couldn't open them. Now, however, it is still not opening. I ...
0
votes
0answers
105 views

pset5 picture problems: jpg recovery

I have two main problems with recover: Does not recover 049.jpg - Is this because my program is getting a freak EOF? check50 hates me - Although my program recovers 000.jpg through 048.jpg fine, ...
0
votes
0answers
97 views

Resize.c Lines are shifted

I have been trying to debug my code for days now with little success. The enlarged image seems shifted when I open it. The white pixels in the middle are skewed off center, though my file is the ...
0
votes
1answer
660 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
0answers
154 views

Unable to solve resize.c

Hello guys I am stuck at pset-5 resize.c problem. Here is what i have done: 1) For updating header, in width and height, ave multiplied them by n and for Image size, subtracted the padding of input ...
0
votes
0answers
149 views

All pictures recovered, Valgrind OK, but Check50 won´t accept the pictures

I was thrilled to see that all the pictures were recovered to the jpg-folder with the correct filenames, but shocked to see that my program was still running! I had to Ctrl + C to end it. I managed ...
0
votes
2answers
240 views

Seg fault in recover.c pset5

I don't know why it's showing seg fault. Could anyone please tell me what I've done wrong? #include<stdio.h> #include<stdint.h> #include<stdlib.h> typedef uint8_t BYTE; ...
0
votes
0answers
166 views

Resize vertically not working. Help!

Okay, my image is coming out a bit shifted and with two dark spots. please help me pinpoint whats going wrong // iterate over infile's scanlines for (int i = 0, biHeight = abs(bi_o.biHeight); i &...
0
votes
1answer
477 views

Error: double free or corruption when running recover

After a very long time, I finally managed to find out why my version of recover.c only managed to recover 1 image (recover.c only recovers 1 image) Anyway, now I face a new problem. What I've ...
0
votes
1answer
288 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 = ...
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
1answer
556 views

Rewrite method in resize.c

I am currently trying to conceptualize the idea of creating the vertical nth copy for resize.c but I don't grasp how the file position indicator can tell when there is a new line. How do I tell C to ...
0
votes
0answers
126 views

open file in binary mode, as opposed to text mode

On the http://www.cprogramming.com/tutorial/cfileio.html web page we can read <>. Well, an image file is actually not a text file. But in another stackexchange answer it is stated that a BMP file ...
0
votes
1answer
59 views

Pset5 is missing from the web site

I just watched the Week 5 lecture and now I notice there is no pset5 accessible on the web site. Do I miss something here? I also notice that there is no Week 6 on the web site.
0
votes
0answers
182 views

check50 fails my pset 5 resize.c even though output is identical to staff's implementation

I ran diff with the bmp file outputted by my resize program and the same bmp file outputted by the staff's implementation, and it says that the two files are identical; but check50 says it doesn't ...
0
votes
1answer
397 views

How does the “re-copy method” work?

So, in Zamyla's walkthrough, she says that for the "Re-Copy" method of vertical resizing, you have to go back to the start of the original row, and then repeat the horizontal resizing. I don't ...
0
votes
1answer
35 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
92 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
126 views

PSET5 - Loads 0 words into dictionary

my code compiles and runs, but loads 0 words into the dictionary. Can you spot what's wrong with it? (As a sample, I tried using the smaller dictionary with a random text file. example syntax: "./...
0
votes
1answer
1k views

Valgrind still reachable memory

For my pset5 speller program valgrind is saying that i have still reachable memory. This is the output: HEAP SUMMARY: ==24516== in use at exit: 352 bytes in 1 blocks ==24516== total heap usage: ...
-1
votes
1answer
132 views

Recover creates 16 corrupt images

Not Sure why my program is not making valid Jpegs! I am almost done!! Anyways, here is my code. I suspect it has something to do with the first write from buffer (the ones that detect jpeg file). #...