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
0
votes
1answer
35 views

Pset5: I get a seg fault when looking for a word that is not in the dictionary

I get a seg fault when running the code below. I ran GDB and what I can tell is that it works well when the word I look for is in the dictionary (e.g. this), but that it does not work when the word is ...
0
votes
1answer
61 views

What causes the seg fault in loading dictionary of pset 5?

When my code runs I get a seg fault. I ran GDB and it crashes where you can see the ***. The strange thing is that in GDB I do not see any value in buffer before the crash, whereas it should have read ...
0
votes
1answer
118 views

Speller only reads one word from the text

I think I wrote dictionary properly but my problem is that speller reads the first word of the text only then gets to the space after and just stops without ending. It is confusing since as far as I ...
0
votes
1answer
78 views

Pset5 segmentation fault in load function using hash table

I always get a seg fault in this specific function. I've checked it with GDB, and the line causing seg fault is hashtable[index]->next = tmp_node. bool load(const char* dictionary) { FILE* dict = ...
0
votes
1answer
43 views

valgrind complains about char* used in load-pset5

Hello everyone I have just completed pset5 and the only issue I have is that valgrind is throwing an error about a malloc'd char* I use in my implementation of load. I know where the error is, but I ...
0
votes
1answer
81 views

Segmentation fault in pset5 during check function

So, I'm doing check() in pset5 and I've found a seg fault in alice.txt while running the small dictionary. I've tested the load() function, so it can't be it. Code: bool check(const char* word) { ...
0
votes
1answer
330 views

cant wrap my head around implementing this trie

So in theory the concept of a trie makes a lot of sense, but I'm really missing something when it comes to putting it down into code. Any help would be soooo greatly appreciated. I've scoured the ...
0
votes
1answer
188 views

PSET5 Dictionary.c issues with implementing Load using trie

I've written some lines of code to implement the trie alogorithm for loading the dictionary. I'm facing the following issue: Compiling speller.c is giving me some errors, one of which is the below: ...
0
votes
1answer
157 views

only loads 1 word in dictionary

Not sure if rest of code works correctly but I cannot get the load function loading more than 1 word. It only loads the first word from the dictionary and no more. Can somebody please give some hint ...
0
votes
1answer
138 views

pset5 check50 seg fault

Making my question more specific: My code is running and producing the same result as the staff's solution (checked all given .txt files with large dictionary and also successfully loaded small and ...
0
votes
0answers
240 views

Check50 on speller

My version of speller works fine against various text files. Ralph.txt reports one misspelled word as the keys/ralph.txt file specifies. But running chek50.speller against my code produces errors, ...
0
votes
1answer
2k views

Pset5 -Valgrind - Conditional jump or move depends on uninitialized values.

So I've got all the functionality down for dictionary.c and there are no leaks. I'm still getting 1 error in valgrind. ==8654== Conditional jump or move depends on uninitialised value(s) ==8654== ...
0
votes
1answer
106 views

expected output, not standard error

My program compiles and runs fine. There isnt even much memory leak. But still it doesn't pass the cs50 check. Link to my check code
0
votes
1answer
181 views

Problem with capitals check() function

I've been having some difficulties with the check function. It seems to work when all the words in my text file are lowercase but any capital letters are returned as misspelled. I iterate through ...
0
votes
1answer
399 views

pset5 issues with load and check. Help!

I'm stuck with load and check and have several issues. At the top of my code I have the following: typedef struct node { bool is_word; struct node* children[27]; } node; node* root; node* ...
0
votes
1answer
120 views

pset5 load function: seg fault, not reading dictionary file

Here's the relevant part of my code for this question: bool load(const char* dictionary) { node* root = malloc(sizeof(node)); //root of the trie char* wordbuf = NULL;...
0
votes
1answer
130 views

Unload-function seems to trigger segfault

I'm having some difficulties with pset5 - Mispellings. My program, which uses a hash-table, seemed to work fine until I implemented the unload-function. I used the function shown in the walkthrough by ...
0
votes
1answer
171 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
0answers
100 views

Apostrophe's not working in pset5

The dictionary works perfectly fine using a simple dictionary and text until I include an apostrophe in the dictionary at which point I get a seg fault in my unload function. The unload function works ...
0
votes
1answer
128 views

PSET5 : Unload Invalid Next Size

I have been having a problem with PSET5 in unload, where it is giving me an error: * Error in `/home/ubuntu/workspace/pset5/speller': free(): invalid next size (fast): 0x00000000006042d0 * ...
0
votes
1answer
385 views

Speller.c: all words in text misspelled

When I run check on my code, it shows that my program marks all the words in the given text as misspelled. I've made sure to pass a lower case copy of the words into my hash function before they are ...
0
votes
1answer
80 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
233 views

Segmentation fault in Unload function

My code seems to work and identifies words in the dictionary but then has a segmentation fault when unloading. I used gdb and found that root->paths[0], should be NULL on the first run but isn't. It ...
0
votes
1answer
125 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
64 views

pset5 load() issue

I'm trying to implement load in pset5, however I'm having trouble putting them into the hash table. What I have is the following: I believe I should be getting an output of the below when I test it ...
0
votes
1answer
149 views

PSET5 dictionary.c getting all words misspelled

i have been working on it for weeks now but for the past few days i have been just trying to find an error.. My program is returning all the words as misspelled.. any help would be highly appreciated ...
0
votes
1answer
46 views

pset5 Mispellings output looks correct but check50 disagrees

Think I've managed to get everything to work. The program compiles and loads large or small dictionaries and finds misspelled words in various text files. I diffed the output of my speller with ...
0
votes
0answers
115 views

Pset5 problem with grading

Can anyone tell me if there is an issue with pset5 grading? I submitted my code two days ago and it passes all tests in check50 besides the last one. I couldn't finger out that one! My grade came back ...
0
votes
1answer
105 views

speller still not working, help please!

I am still trying to finish the speller pset but without success. I can now get it to compile but its output is incorrect. When I create a smaller dictionary and test text file, with 12 words ...
0
votes
2answers
78 views

pset5 check wrong if condition

This is how code looks before functions in dictionary.c typedef struct node { bool is_word; struct node* children[27]; } node; node* root; The load function works fine, but when the program ...
0
votes
1answer
268 views

pset5 load segmentation fault

After a first couple of runs it loaded first two words of the large dictionary and after that I got seg fault. All other attempts after got me seg fault on the beginning. Here is my code. Anyone knows ...
0
votes
1answer
358 views

Pset5 memory leak with unload

I have completed the code for pset5 but I have a super big memory leak which i believe comes from not pointing each backed in the hash_table correctly. Below I have unload function and valgrind's ...
0
votes
1answer
138 views

Speller.c - need help on check

For an unknown reason some words that are in the dictionary and in the text file as well are marked as misspellings in the statistics. Though, the code passes check50 except the last paragraph saying ...
0
votes
1answer
154 views

pset5 load() seg fault and malloc problems

I've been having great difficulty with implementing the load() function. bool load(const char* dictionary) { // Define node structure typedef struct node { bool is_word; ...
0
votes
1answer
47 views

Segmentation error in load

This is the second time I started the pset5 from scratch. This time, when I am running load for small dictionary i get the message that text couldn't be found. When I run the function for large ...
0
votes
1answer
101 views

Can't even get GDB to run on my speller file

I won't even say how long I have been working on pset5, its embarrassing. But I have now at least got code written which I am sure is going to have a lot of mistakes. Problem is I can't even run GDB ...
0
votes
1answer
136 views

Segmentation fault

The code is working for loading large dictionaries most of the times but when i am trying to load a small dictionary i get the message that dictionary couldn't be loaded, while after that when i am ...
0
votes
1answer
271 views

Pset5 load clang error: linker command failed with exit code 1

I have been working on the load function for pset5 for more than 2 weeks and I am keep receiving clang error: linker command failed with exit code 1. Bellow I have the code so everyone can take a ...
0
votes
1answer
230 views

pset5 segfault in unload

FINAL EDIT My function that frees the memory works properly; the problem lies in node creation. I now have a separate problem where the program segfaults when run normally, but it cannot be ...
0
votes
1answer
77 views

pset5 root node not freed

It looks like my unload function is not working properly. Valgrind shows 0 errors, but when I print out the address of my root node, it is not NULL. Hence my unload function (which returns true if ...
0
votes
2answers
158 views

Segfault in pset5 in load

My implementation of load uses a trie and when I attempt to access the bool is_word I get a segfault. Can you guys help me out? Any suggestions on how to improve my code would be amazing. Thanks ...
0
votes
1answer
520 views

pset5 check function error using tolower with const char*

Below, I want to turn each letter in the array of word into lower case. I'm using a loop and tolower to change each letter. But I get this error when I compile: dictionary.c:44:33: error: read-only ...
0
votes
1answer
90 views

pset5 Load has garbage values in GDB

Code for load is below. When I go to GDB and print new->word a couple steps after the while statement (with the fscanf), it gives the following: "\000\000\000\000\203\212\343\267\003\000\000\000\204\...
0
votes
1answer
128 views

pset5 invalid reads/writes

My speller programs compile and run with no issues however valgrind doesn't seem to think so. I initially used malloc and manually initialised each pointer to null and the boolean to false. I have ...
0
votes
2answers
303 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
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
2answers
1k views

Pset5 Speller - segmentation fault is driving me crazy!

Hey guys! I have been working on pset5 for a while and I keep on obtaining a seg fault. I have alreay run valgrind but it gives me no error. I cannot really see where is the problem. Any help will be ...
0
votes
1answer
168 views

Trouble debugging Unload… values “optimized out” in GDB

I've been having trouble debugging my Unload code because when I try to print the values of variables in GDB, I get that the values have been "optimized out". Is there any way to see what those ...