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.

254 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
1answer
71 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
18 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
45 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
28 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
39 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
47 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?
0
votes
0answers
30 views

I keep getting seg faults when running code

I've been looking through my code, but I'm unable to figure out why my code keeps seg faulting. I used my own custom hash function to take the first character of each string in the dictionary to 26 ...
0
votes
1answer
203 views

PSET5: Code works but doesn't qualify for big board?

Whenever I run this code, it works, but then when I use check50 it says that it doesn't qualify because it timed out while waiting for my program to exit. https://cs50.me/checks/...
0
votes
1answer
381 views

How can I debug my load() function in Speller?

So I have code that I feel as though should be working, but I'm having trouble checking my work. I wrote a function that I think loops through my table, but it only displays half of the data seemingly....
0
votes
1answer
43 views

How can I tell if I'm analyzing my Speller load() results correctly

As far as I can tell the code I have seems correct, though when I try to print out what my table contains, I get repeats of the same value. I can't tell if I am printing the data from my hashtable ...
0
votes
1answer
41 views

Pset5 Speller dictionary entries getting overwritten

I'm having problems with pset5 speller where the words I load into my dictionary hash table are getting overwritten. So for example if I load "Ashley", "Britney" and "Charlie" into my dictionary, all ...
0
votes
0answers
25 views

Valgrind throws a memory error and I think it's not okay with mouse set to NULL. I don't know how to fix it. Please help

bool unload(void) { node *cursor = NULL; node *temp = NULL; for(int i = 0; i < 26; i++) { cursor = hash_table[i]; ...
0
votes
0answers
22 views

PSET5 - Test example implementation of linked list array gives realloc() error

I've tried making a test implementation of a linked list array to understand linked list arrays better and try to implement it in my code. I tried storing chars inside a linked list array which worked ...
0
votes
1answer
868 views

Incompatible pointer types even though they are both char*?

dictionary.c:70:20: error: incompatible pointer types passing 'char *[46]' to parameter of type 'const char *' [-Werror,-Wincompatible-pointer-types] if (strcmp(checker->word, lowword) == 0) ...
0
votes
1answer
293 views

PSET 5 Spell Checker - Error: Could not load dictionaries/large

I would be so grateful to anyone who can help me figure out this issue. After finally getting my code to compile I was met with the following terminal error when attempting to run the program: "...
0
votes
1answer
23 views

Why am I able to insert an element into a hash tree via Main() but not via a function call?

I'm fairly certain this has something to do with pointers and the function using copies instead, but I'm not sure how...because I've inserted the pointer as a parameter for create(); #include <...
0
votes
1answer
32 views

pset5 memory leak: should freed memory but didn't

I need to operate p in the for loop, therefore I made a copy of the p pointer, and I free p_malloc_orig at last. But the memory is acutally not freed. Where did I possibly do wrong? char *p = malloc(...
0
votes
1answer
52 views

Segmentation fault in pset5/speller while linking newNode with the linked list

I have been trying to resolve errors in my speller "load function". I have been able to resolve a couple of them except this one. Debug50 reveals that while creating a link between new Node and the ...
0
votes
1answer
340 views

Pset5 speller: how can I navigate through the Trie and free the nodes?

so I am stuck on this PSET5 speller for a quite while now, trying different approaches, looking at available information in CS50, shorts, pset problem explanation and I couldn't get to free all the ...
0
votes
1answer
104 views

cs50 pset5 hashtable check, misspelled more than expected

i have been working on the check for many days and not able to find why the misspelled word is more than stuff solution. Rest of the programs looks ok, and i used debug50 ,there is not too much clue. ...
0
votes
1answer
131 views

Pset5 Memory leak and errors in valgrind

I have been beating my head against a wall trying to solve my issues on my own, but I have gotten no where. I have two issues: 1) I have a small memory leak of 568 bytes in 1 block. My unload function ...
0
votes
1answer
106 views

Pset 5 (speller): Problem with compiling due to 'declaration shadows a variable in the global scope;

I am using the trie structure for doing the pset5 speller. However, my program can't compile due to 'redefinition of node' in 'typedef struct node', and 'declaration shadows a variable in the global ...
0
votes
1answer
455 views

Pset5. How to make speller code take less time?

//define node structure typedef struct node { bool is_word; struct node *children[27]; } node; //pointer to the first element of trie node *root; //counts number of words int words = 0; //...
0
votes
2answers
69 views

PSET5 Speller Trie Errors

So far, all other methods except check have already been implemented properly in my code. The problem with check is that it only returns true a lot fewer times than expected, which means that most ...
0
votes
1answer
207 views

pointer disappeared after passing to some functions (even with malloc)

I created a test.c for testing purpose. My problem is that I created a pointer at the bottom Main. Main will call load() to read input from a dictionary and insert the words in a inputfile into a ...
0
votes
1answer
293 views

pset5 speller trie load - Dictionary not loading

I am working through pset5 using the trie data structure and it has been very challenging. I finally have code that compiles but when I run it against cat.txt using the small dictionary it returns all ...
0
votes
1answer
43 views

Does anyone know how to fix this problem?

this error is in every check50 test. Conditional jump or move depends on uninitialised value(s): (file: dictionary.c, line: 92) Conditional jump or move depends on uninitialised value(s): (file: ...
0
votes
0answers
60 views

Printf prints newline character instead of string in Pset5

I'm working on the Speller program in Pset5. As always, i'm using a modular approach to construct all the required constituent functions one by one. However, something quite odd is happening in my ...
0
votes
1answer
42 views

Last word of dictionary file replaces all the nodes in node bucket

Currently I am working on the load function using a hash table with singly-linked list. I have tested the create(), insert(), and find() function in a separate file and they work as expected. ...
0
votes
0answers
45 views

can’t pass valgrind in pset5

I don’t know where is the error and when i use help50 that what i get and here is the code unsigned long hash(char* str); int count ; int table_size = 18788; typedef struct node { char word[...
0
votes
1answer
119 views

PSET5: Unloading function doesn't work

I've decided to implement the trie data structure and got everything working except the unloading part. I've written another function for it and it isn't working. I think it only frees the first few ...
0
votes
1answer
77 views

PSET5. Free a variable outside a loop. leaking memory

I've been stuck for days in the implementation of LOAD with a TRIE data structure. I think my code works (well it doesn't show seg faults) but I am getting a lot of memory leaks. I implemented the ...
0
votes
1answer
65 views

pset5/speller incorrectly identifies correctly spelled words

I do apologise for the unspecific question, however I have been slaving away at this problem set for almost two weeks and have only just managed to get code that compiles. I have reached my wits end. ...
0
votes
1answer
847 views

CS50 Speller Pset5 - Comparing succeeds, Check50 fails and Valgrind succeeds

Comparing output with ~cs50/pset5/speller texts/austinpowers.txt returns successfully and valgrind works. I don't know why Check50 gives an error. I would appreciate some help please. Check50 NOW ...
0
votes
0answers
51 views

pset5 load(trie) is not loading

i dont know what am doing wrong in my load function but my speller says it cant load, please shed some light on where am doing wrong. * Implements a dictionary's functionality. */ ...
0
votes
1answer
276 views

pset5 speller (using tries)

When I run my program, the program output every single word in the text instead of solely misspelled words. I'm fairly confident the problem lies within my load function. Can someone identify anything ...
0
votes
1answer
137 views

i don`t know what is wrong with my unload function?

enter code here /** * Implements a dictionary's functionality. */ #include <stdbool.h> #include<cs50.h> #include <strings.h> #include <stdio.h> #include <...
0
votes
1answer
151 views

pset5 - speller (Trie) : Too many allocs and of too much sizes

Speller was really tough for me, had to learn a lot of extra material to get it right. But still, even though I've used trie, I've implemented the solution rather very inefficiently. Here are some ...
0
votes
0answers
45 views

Pset5 Speller Tries: How do I copy a character from word into children?

I am using Tries to load dictionary into memory and I am stuck trying to copy characters from the source word into children[] that is part of a new_node structure definition: typedef struct node { ...
0
votes
1answer
583 views

pset5 dictionary c. trie please help Unload()

i ve been working struggling so much... please, a hint why i can make it work. I don t know how to return the result and make sure that the conditions are followed. here are my codes for unload : ...
0
votes
1answer
84 views

Stuck on Pset5: segmentation fault. Debug?

I am completely stuck at pset5, and I don't know how to move on. I've tried to write code for all the four functions, but I strongly doubt that it is any good. It does compile, but 'speller.c' does ...
0
votes
1answer
481 views

Pset5 speller trie

There is a problem with my load function which i cannot wrap my head around. I can run speller however because of this one problem, my misspelled words is always more than the actual value. What is ...
0
votes
1answer
1k views

Speller seems to be working but fails check50. (PSET5)

so currently my speller seems to be working, it matches the staff solution with the austinpowers.txt (correctly identifies that 644 words have been misspelled & works when using a small dictionary ...
0
votes
1answer
47 views

PSET5 Dictionary code compiles but doesn't run as expected

I have been sitting on this pset for weeks but i have not figured what i wrote wrongly.. I implement the solution to this problem using a trie, however i think my trie is not properly linked/connected....
0
votes
0answers
127 views

pset5 - program runs fine but check50 still fails

My speller code works fine, I've compare it with the staff solution with different texts and dictionaries and everything is exactly the same (words in dictionary, words misspelled, words in text) but ...
0
votes
0answers
59 views

pset5 segmentation fault after check50 passed

After fixing and running pset5 most recently yesterday, it made it through check50 with no errors -- all smiley faces. I ran valgrind and found a number of leaks which were repaired by removing an ...
0
votes
1answer
51 views

Segementation fault in speller.c/pset5

I am working on speller.c/pset5 and when my code I get a segmentation fault.Plse let me know where am going wrong. I had my hands over debug50 as well but I can't figure out what's wrong. Any ...
0
votes
1answer
206 views

Running time of speller.c/pset5

I am stuck into this for long and seems like no way out. I have tried implementing speller.c/pset5 using hashtables and my code passes check50 but I get a total running time of 0.5 on an average ...
0
votes
1answer
157 views

Problem in load function

Why does the code in the wile loop inside the load function only get executed once? /** * Implements a dictionary's functionality. */ #include <stdbool.h> #include <stdio.h> #include &...
0
votes
2answers
123 views

Loading my dictionary into a data structure speller.c/pset5

I have just started with speller and wanna know that though I have to keep my runtime short how may I use hash tables for that because they have a constant runtime (in search) for every node to be ...