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

Pset5 Speller Issues with check and unload functions

I have been stuck on this pset for over a week now. I have already checked other answers to similar questions here but none have been helpful to me. Testing through check50 as well as the debugger I ...
0
votes
1answer
20 views

PSET5: Missing Words from Text and Memory Leaks

UPDATE: I just fixed the capitalized spell-checking errors. UPDATE 2: free didn't totally free the string "caterpillar". Look at image: My code seems to encounter a weird bug where it does ...
0
votes
1answer
30 views

pset5/speller Check produces a segfault if I introduce hash function

If I have a single bucket, the program runs seamlessly, however when I introduce the djb2 hash function as seen here the program produces a segfault. Here's my code with the hash function commented as ...
0
votes
1answer
34 views

Pset5 Speller. Treating the letter 's' as a valid word when using large dictionary?

I'm very puzzled my program seems to work correctly apart from one thing, when I run speller with large dictionary, the letter "s" is treated as a correctly-spelled word. I ran a test using ...
0
votes
1answer
97 views

Pset5, Speller, output the same as staff, but check50 still showing entirely errors

I'm stuck on Pset5, Speller. My code all compiles correctly, and when run on the Lala Land example, provides the same output as the staff solution (albeit mine runs more slowly). But, check50 still ...
0
votes
1answer
55 views

I dont understand valgrind pset5

Error from valgrind $ valgrind ./speller texts/cat.txt ==1453== Memcheck, a memory error detector ==1453== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==1453== Using Valgrind-3.13....
0
votes
1answer
139 views

Pset5 - Speller - memory leak?

My programme runs and I'm passing all the checks bar the last one. When I run the check with --log I get this response: :( program is free of memory errors valgrind tests failed; rerun with --log ...
0
votes
1answer
114 views

PSET 5 Speller - Unload leaking a ton of memory

I've been trying to read other questions on stack exchange about it and do research on it but I really couldn't find a solution for my unload problem. It doesn't seem to unload much. I tried a lot of ...
0
votes
1answer
69 views

Please help! I'm stuck on Pset5 Speller!

#include <stdbool.h> #include <stdlib.h> #include "dictionary.h" #include <string.h> #include <stdio.h> #include <ctype.h> int wordCount = 0; // Represents a ...
0
votes
1answer
36 views

Speller - not sure what's wrong

I'm struggling trying to find what the error is or why speller is behaving the way it is. Currently, when I run help50 valgrind, I get this error message: ==8634== 56 bytes in 1 blocks are definitely ...
0
votes
1answer
49 views

PSET5 Speller - Can't handle substrings properly

I've been doing the speller exercise for a while and I'm stuck in the "handle substrings properly". Here's my code: // Implements a dictionary's functionality #include <stdbool.h> ...
0
votes
1answer
30 views

CS50 (Speller) returns all words as misspelled

I'm right on the verge of cracking this problem. I ran the program on the small dictionary provided in the distribution code. It returned both words as misspelled. So I debugged the program. I noticed ...
0
votes
1answer
43 views

Pset5 - ( program is free of memory errors valgrind tests failed; rerun with --log for more information

Please assist me how to resolve such an error. see my code below: // Scans dictionary word by word (populating hash table with nodes containing words found in dictionary) char word[LENGTH + 1]; while (...
0
votes
1answer
29 views

pset 5: Repeat Until?

Trying to read strings from file in the [load] function of speller. When using fscanf(), how do I start a while loop until it returns "EOF"? I think there's got to be an easy way to do this, ...
0
votes
1answer
37 views

PSET5: Trying to implement dictionary.c using trie. But segmentation fault in check()

My implementation compiles but I am getting a segmentation fault when I execute. My program is working fine through the load function because the output screen shows this "~/pset5/speller/ $ ./...
0
votes
1answer
67 views

PSET5 Compiling issue

So I finally finished my code and received 20 errors when attempting to compile, after my first attempt fixing the errors I tried again and received 15 errors, once more and received 17, and now am ...
0
votes
1answer
58 views

valgrind Pset5 error

All checks with check50 are green except the memory error. This is what valgrind shows me: ==3259== ==3259== HEAP SUMMARY: ==3259== in use at exit: 8,013,096 bytes in 143,091 blocks ==3259== ...
0
votes
1answer
61 views

Pset5 speller getting valgrind error

My code // Implements a dictionary's functionality #include <stdbool.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <...
0
votes
1answer
29 views

pset5 speller: valgrind 937 errors from 1 context

I have done check50 and the only error is "valgrind tests failed; rerun with --log for more information". I can't find the source of the memory leak and I thought that my unload made sense. ...
0
votes
1answer
42 views

PSET5: memory leak in check function

bool check(const char *word) { unsigned int hash_index = hash(word); node *trav = table[hash_index]; while (trav != NULL) { int len = strlen(trav->word); char ...
0
votes
1answer
31 views

PSET 5 SPELLER - seg fault

I need help with my unloads function. I keep getting a segmentation fault on "while(cursor->next != NULL)." When I hover over the "cursor->next" part it says no value. I don'...
0
votes
1answer
188 views

Pset5: strcasecmp doesn't return 0 when given the same string input

// Implements a dictionary's functionality #include <stdbool.h> #include <strings.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <ctype.h> ...
0
votes
1answer
25 views

Pset5 : Valgrind seg fault in load function

Currently doing the pset5, and keep getting seg fault when running Valgrind. This is the error messsage I get: /etc/profile.d/cli.sh: line 94: 1150 Segmentation fault valgrind ./speller texts/...
0
votes
1answer
35 views

My code matches the outputs in the keys, but does not pass check50

The code is here: // Implements a dictionary's functionality #include <stdbool.h> #include "string.h" #include <strings.h> #include <ctype.h> #include <cs50.h> #...
0
votes
1answer
65 views

PSet5 Speller, passing test cases but not check50

I'm implementing the most basic form of the speller function, using 27 buckets for A-Z and ' (apostrophe) . My code works for the test cases (i.e. the generated results match those in keys/) but when ...
0
votes
1answer
106 views

PSet5, Speller, all correct but problem with Valgrind

I am so close to finally finishing Speller, however I'm running into an issue with Valgrind that I don't understand. I was under the impression that when I malloc a node for the dictionary table in ...
0
votes
1answer
23 views

dictionary is allways null

// Implements a dictionary's functionality #include <stdbool.h> #include <string.h> #include <stdio.h> #include <ctype.h> #include "dictionary.h" // Represents a ...
0
votes
1answer
103 views

pset5 speller, passes all Check50 requirements except the last one (Valgrind)

My code is now working fine but misses out on fully completing Check50 because of the last requirement. Running ~/pset5/speller/ $ help50 valgrind ./speller texts/cat.txt, it returns: ==6259== ...
0
votes
1answer
38 views

PSet5 Speller, Load Function, help50 Valgrind returns “==2480== Conditional jump or move depends on uninitialised value(s)” at the strcpy line

I've been working on Speller for a while now, but I've been stuck on this same problem. When testing my code by running ./speller texts/ANYOFTHETEXTS, it says I load 143092 words, but it also always ...
0
votes
1answer
26 views

pset5 speller everything works but the program won't end

okay so i have done everything correctly in terms of getting the right results i get a correct number of misspelled words and the time is low enough. i just can't get the program to end. val grind ...
0
votes
1answer
54 views

Speller.c doesn't work

I've spent pretty much time trying to solve a speller and got really stuck, don't know what's wrong with my code. It compiles but check50 says it's totally incorrect. I would be grateful if you could ...
0
votes
1answer
57 views

PSET 5 Unload Segmentation Fault

I've been stuck on this problem set for a while now. Valgrind is telling me I have a problem in my unload function, which is "Conditional jump or move depends on uninitialised value(s)". I can't find ...
0
votes
1answer
99 views

pset5 speller “Could not load dictionaries/large”

I cannot figure out what I am missing. Program keeps returning "Could not load dictionaries/large" I have checked and tried different suggestions from similar questions but I do have the folder ...
0
votes
1answer
18 views

Pset5 Speller: Valgrind error with bool check

I solved every memory leak I had, but I'm having some issues with this one. What's a good method to free memory from node* checker in this case? bool check(const char *word) { node *checker = ...
0
votes
1answer
44 views

Speller Load doesn't see certain words

My load function sometimes overlooks certain words in the dictionary. For example it jumps over the word "nodes" instead of loading it into the hash table. bool load(const char *dictionary) { // ...
0
votes
2answers
53 views

Memory issue (Valgrind “Still reachable”)

My code seems to pass all the Check50 tests except the one for memory as valgrind returns a "still reachable" error. Not sure what needs to be done, any help will be appreciated. Thanks! My Code #...
0
votes
1answer
59 views

PSET5 check50 fail but same expected output from actual

I've seen a similar post about this but I couldn't really figure out why my code doesn't pass check50. It might be on the load function, but I'm not entirely sure. I already ran the code with the ...
0
votes
1answer
108 views

CS50 PSET5 Speller Valgrind error: still reachable: 8,013,096 bytes in 143,091 blocks

I have got this Valgrind error for my code. I know that I have not freed the malloc of new_node but I still could not solve this problem after trying many different ways. Can anyone help:( // ...
0
votes
1answer
243 views

cs50 pset5 speller check function too slow

When I run my speller program, everything compiles fine and the results are accurate, but the check function seems to be way too slow (takes ~7seconds) compared to staff's version(~0.2 seconds) and so ...
0
votes
1answer
49 views

Pset5 Valgrind Error: Reachable Memory

I've been on the speller problem for a while and I don't understand where i'm going wrong. Any help would be much appreciated. I'm getting the following error from valgrind when i run it alongside --...
0
votes
1answer
75 views

Hello! I am stuck on pset5 speller

When I compile my code it gives correct results, but doesn't pass check 50. Could please anyone help me to find a mistake, thank you. #include <stdio.h> #include <stdlib.h> #include <...
0
votes
1answer
109 views

i keep on getting segmentation fault in pset5

// Returns true if word is in dictionary else false bool check(const char *word) { //change letters to lowercase int length = strlen(word); char copy[length + 1]; for (int i = 0; i < length;...
0
votes
1answer
142 views

Pset 5 Speller valgrind error

I am trying to fix the last error in my code pointed out by check 50. I think the problem is in my unload but can't say for sure. Here's my code. I know I have some basic functionalities wrong but ...
0
votes
1answer
22 views

Pset5 Seg fault speller

I´ve been stuck in pset5 for a little while. I was wondering if someone would be able to take a loot at it? Fow now all my hash function does is look at the first letter of a word. I will of course ...
0
votes
1answer
25 views

PSET5 Unload() recursive sub-function causes 112 bytes to leak - why?

I've already fixed this issue playing around with my code, but I cannot seem to understand why this (former) version of my recursive function leaks 112 bytes (2 nodes). Can anyone please help me ...
0
votes
1answer
134 views

SPELLER(pset5), output of misspelled words is more than actual

There are two problems with the code: WORDS MISSPELLED are around five time normal. It is showing 5440 misspelled words while ideally there are around 900 such words(staff's solution). In the bool ...
0
votes
1answer
64 views

CHECK50 ERRORS IN SPELLER PSET

Here is my code for the pset I am getting 2 errors after check50. I am not able to get hold of any loopholes in the code. Kindly help! 1) :( handles max length (45-char) words expected "MISSPELLED ...
0
votes
1answer
32 views

speller giving error on valgrind, using 4 bytes of memory that isn't yours…indexing an array out of bounds

I think the problem with is the load() function, here is my code: bool load(const char *dictionary) { char *s = malloc(LENGTH + 1); FILE *f = fopen(dictionary, "r"); if (f == NULL) { return false;...
0
votes
1answer
130 views

PSET5 - Speller - Doesn't display anything past MISSPELLED WORDS

I've been debugging for quite a while now and can't seem to figure out the solution to this problem. When I use the large or small dictionary on any of the texts, the program becomes stuck at ...
0
votes
1answer
38 views

Confused with Memory Leak in pset5 Even Though the Problem is Fixed. What was wrong with my size function?

Thank you in advance for taking a look at my code. I have been getting this error below: ==4734== 8,011,640 bytes in 143,065 blocks are indirectly lost in loss record 1 of 2 ==4734== at ...

1
6 7
8
9 10
24