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
0answers
87 views

Pset 5 - Error with freeing up memory - Use of uninitialised value of size 8

I am working on Pset5 and the only issue I am having is regarding the requirement for freeing up memory. Based on the output received from Valgrind, it looks like there is no issue with the memory ...
0
votes
0answers
20 views

Pset5 - Segmentation fault (Load function) - Using a for loop to make all elements of table[i] = NULL

The following is my load function and I am having a segmentation fault when I run the executable code by typing for example when I type ./speller texts/aca.txt When I run debug50, it is pointing to ...
0
votes
1answer
104 views

Pset5 speller fail to check50 (update : cannot print the report of benchmark in check50)

=================================UPDATE=================================== Because one of the failed to spell-checking is case-insensitive of check50, I think maybe the problem is caused by my hash ...
0
votes
1answer
52 views

I keep on getting a segmentation fault in pset5, please help

typedef struct node { char word[LENGTH + 1]; struct node *next; } node; // Number of buckets in hash table const unsigned int N = 100; //Size of dictionary int size_of_dic = 0; // Hash ...
0
votes
1answer
62 views

Pset 5 Speller: Identifying all words as misspelt

I was wondering whether anyone would be able to identify the issue with my code for Speller. I think that I should be nearly there but I'm struggling to work out why my code identifies every word as ...
0
votes
0answers
40 views

Need help fixing memory leaks

I need help fixing the memory leaks on the code! I have already tried fixing them, but I have no clue how to do so. Here is the complete code: // Implements a dictionary's functionality #include &...
0
votes
1answer
61 views

Failing miserably on check50 and valgring, even though all my answers match exactly the staffs' keys

I don't know why my code is falling on check50! It seems like it is blowing the time limit. Is it possible? I ran my program with many texts, and the results always match the staff's key. Can ...
0
votes
2answers
23 views

freeing temporary node in functions

how to free the temporary pointer, one creates during the check function? valgrind shows error on that particular statement tried freeing it only when it has reached null, i.e., transverse over all ...
0
votes
1answer
12 views

My parameter isn't being recognized, although it's a constant

///Here's my load function bool load(const char *dictionary) ///Here's a later part of my program unsigned int size(void) { if (load(dictionary) == false) { return 0; } return ...
0
votes
1answer
29 views

Pset5 load problem: Dictionary cannot be loaded

I run my code and it cannot load the dictionary. I'm not sure if the problem is with my code or the file location. Anybody knows why? Thanks in advance.
1
vote
1answer
257 views

My check function in speller isn't working

I have implemented everything else but this check function when I try to test it it seems like the the check function isn't working, because the no. of misspelled words is the same as the no. in text.....
0
votes
1answer
78 views

PSET5: Check is not working properly…i think

When I test my code...it counts most words as misspelled and only 1 or 2 words as being in dictionary..i presume the issue is in the check function...i do believe the load function works just fine as ...
0
votes
0answers
59 views

PSET 5 (speller): I don't know why I receive an inaccurate count for words in dictionary

unsigned int size(void) { int count = 0; for (int i = 0; i < N; i++) { for(node *temp = table[i]; temp != NULL; temp = temp->next) { count++; } } ...
0
votes
1answer
24 views

I don't get why the pointer to next in the node is “new” and not “head”, can someone please explain?

I'm practising using Linked Lists, and trying some exercises here: https://study.cs50.net/linked_lists Here's an exact copy-paste of the code found at the bottom: #include <assert.h> #...
0
votes
1answer
24 views

small memory leak in pset 5

My code is leaking just 276 bytes of memory in pset 5, and I am at a loss to understanding where it is. Using help50 and valgrind, I get the advice: Looks like your program leaked 276 bytes of ...
0
votes
1answer
60 views

Pset5 Load function memory leak

Valgrind tells me I have a leak with malloc'ed node below. However, when I try to free it (free(n);) at the bottom of my code, outside the while loop, the program won't run (it doesn't pass check50 ...
0
votes
1answer
403 views

Segmentation fault in Speller CS50

Similar to others, I have been getting a segmentation fault on Pset5, though my code compiles and valgrind doesn't flag any errors or leaks. I am not exactly sure what to look for with seg faults, so ...
0
votes
1answer
48 views

Help with pset5 'recover': incomplete jpgs

I´ve been working on recover for the past few days and I am having some trouble getting a working solution. The code below prints out 49 jpgs instead of 50, and they are all incomplete or very blurry. ...
0
votes
1answer
102 views

Problem Set 5 - Speller (Load and Check function) segfaults

I have a somewhat okay understanding on how linked lists worked since I've had some experience working with them in high school. However, I keep running into these pesky segfaults and I have no idea ...
0
votes
1answer
28 views

Pointer Initialization and Free, Help!

If you initialize a pointer (trav) and assign it another pointer, should you and what happens if you free trav? thank you! node *table[N] = { NULL }; trav = table[i]; Also, should malloc be called ...
0
votes
0answers
33 views

Pset5 Speller HELP!: Code looks fine but segmentation fault. Also, when should I malloc and when should I point to NULL?

I can't find what is the problem(s), been at it for days, please help! thank you! #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <strings.h> #include <...
0
votes
0answers
39 views

PSET 5 - Valgrind - Invalid read of 8 - Unload

So close to submission! - However, when I check using valgrind the ouptut is: ==22743== Invalid read of size 8 ==22743== at 0x40135C: unload (dictionary.c:123) ==22743== by 0x400E59: main (...
0
votes
0answers
37 views

Help on Pset5 Speller

bool load(const char *dictionary) { // Open dictionary FILE *dict = fopen(dictionary, "r"); if (dict == NULL) { printf("Could not read.\n"); return false; } ...
0
votes
0answers
57 views

Pset5 speller: segmentation fault

My code compiles correctly but when I load a text, there's a segmentation fault error. I tried to isolate the problem by commenting out certain code and the problem seems to be at this part. Would ...
0
votes
0answers
79 views

pset5 segmentation fault load() function

I'm getting a segmentation fault when I run speller. The valgrind output is as follows. I think it's due to the load() function. Valgrind output: ==8612== Copyright (C) 2002-2017, and GNU GPL'd, by ...
0
votes
1answer
91 views

pset5 - almost all words misspelled

I'm having trouble with the implementation of the PSET5 spell check code. I've looked through a lot of CS50 Stack Exchange posts, but haven't found any help. The problem is either in the check or in ...
0
votes
1answer
78 views

why pset5 works with small dictionary but with large dictionary gives munmap_chunk(): invalid pointer Aborted error?

I have been following all the instructions very carefully and have been able to come up with a code that looks like it should be doing all the steps needed in every function, I would say. When I ...
0
votes
1answer
76 views

pset5- speller: first word and any word above 7 characters is not recognized

The 'speller' program considers any word with more than 7 characters as misspelled, even though that word is there in the dictionary. Same treatment is given to any word which comes first in the file, ...
0
votes
1answer
83 views

pset5: speller finally two error about words in dictionary

where the error #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "dictionary.h" #include <ctype.h> #...
0
votes
1answer
501 views

pset5 speller case-insensitive

I have couple error I don't understand them at all first case-insensitive I write strcasecmp and still have an error bool check(const char *word) { int num = hash(word); for (node *c = ...
0
votes
1answer
312 views

pset5 speller unload function

I tried two methods but still, have a memory leak and also I didn't know how I know every step succeed or not. it supposes return true if free all memory and return false is not where I must write ...
0
votes
1answer
260 views

pset5 speller could not open text

load function looks good I think the error in speller.c when I wrote ./speller texts/lalaland.txt output: MISSPELLED WORDS Could not unload dictionaries/large. when wrote ./speller text output: Could ...
0
votes
1answer
39 views

Pset 5 Speller. I get segmentation fault. The problem seems to be in the load function, when creating a linked list

#include <stdbool.h> #include <stdlib.h> #include <string.h> #include "dictionary.h" #include <ctype.h> #include <stdio.h> int wcount = 0; // Represents a node in a hash ...
0
votes
1answer
70 views

(PSET 5) Test for case-insensitivity fails

I used strcasecmp for comparing the words case-insensitively. However, check50 showed that I failed the test for case-insensitivity. I believe that my programme treated foO, fOo, Foo, fOO, FoO, FOo ...
0
votes
1answer
97 views

Speller - Unknown issues

I have been trying to figure out the issue with my code for speller, but cant seem to find where the problem is. I have an intuition that it is somewhere in the check or Hash function. The program ...
0
votes
1answer
38 views

And one more “Invalid read of size” problem

So I've managed to write a program, which compiles, cleared all the segmentation fauls, made it to do all the required tasks correctly, like creating a hash table, cheacking for the misspelled words ...
0
votes
1answer
179 views

Pset 5 Speller recursive unload

I've tried implementing a recursive function to free every node in each linked list in the hash table but it turns out it doesn't seem to free any memory as Valgrind shows there is a leak when calling ...
0
votes
1answer
201 views

Pset 5 Speller Linked List Nodes

I thought I got pointers but I don't fully understand a function that gets a new node for a linked list. I understand the theory behind Hash tables and chaining with linked lists but when it comes to ...
0
votes
2answers
523 views

Pset 5: Speller, check or load issue

It seems that Speller has tripped up many people. I searched through previously-asked questions but either it wasn't my problem or I had trouble understanding how I could implement the answers in my ...
0
votes
2answers
148 views

Unknown memory leak on “check function” - CS50 Speller

I have trying to decode the information gathered through valgrind with no success. I followed the hints given by valgrind trying too free the malloc'ed node *checker but to no avail. I've searched ...
0
votes
1answer
16 views

a:hover and a:active tags not editable in html/css

I'm trying to make a homepage as per the pset5, and want to change the color and decoration of hyperlinks. The a:link and a:visited tags were editable, but not the other two. Here's my code for ...
0
votes
1answer
47 views

Speller TRIE - all words misspelled?

I've hunted through StackExchange for similar questions and their advice but I'm still struggling to understand why my speller keeps throwing back all the words as misspelled? Would be massively ...
0
votes
1answer
126 views

Speller pset (check function) problem

I'm not sure what exactly is wrong with my code. I ran it through Valgrind, which says "Looks like you're trying to use a variable that might not have a value? Take a closer look at line 145 of ...
0
votes
1answer
39 views

Declaring a node (a struct pointer) from a function

I'm tackling load and decided to make a create_node function for allocating memory, NULLing all children and setting is_word as false. What I wrote is essentially the same as in this question struct ...
0
votes
1answer
26 views

Why do I get a sanitiser error when creating this node loop?

This is the loop node *root; root = malloc(sizeof(node)); for(node *ptr = root; counter < length_of_input ; ptr = ptr-> a_node) { if(counter != 0) { ...
0
votes
1answer
55 views

pset4 speller unload trie leaking memory

I can't seem to figure out why my code is leaking memory, I think I have implemented recursion correctly, take a look at my unload code. EDIT : I tried running my file with large dictionary and using ...
0
votes
1answer
43 views

Pset4 speller segmentation fault in check functions when using larger files like holmes.txt

I updated my hash function to make the code faster, it makes a hash table and stores word with the same first three letters in one linked list, i.e words starting with aaa will go together, words ...
0
votes
1answer
31 views

Pset5 Trie Segmentation fault

Have been trying to debug this for days and eventually came down to the following problem: When running an example test(lalaland.txt) the misspelled words are fine up until the program abruptly stops(...
0
votes
1answer
38 views

How Do I insert information into a trie?

I'm trying to insert true into the second branch of a node. #include <stdbool.h> #include <stdio.h> #include <stdlib.h> typedef struct node { bool correct; struct node *...
0
votes
1answer
46 views

pset5 speller IDE and check50 show different outputs even though theyare run with the same code

When I run my speller code, it works perfectly fine in the IDE. However, after seeing check50, the output appears to be the following Anyone knows why this happens and how to fix it?

1
3 4
5
6 7
24