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

PSET5 Speller (unload) - “Process recieved SIGABRT: aborted”

I can't seem to find the problem with my code, can anyone help me? //recursive function for unload - to unload a node, first unload all its //children, then unload the node itself bool recursive(...
0
votes
1answer
129 views

pset5 speller (hash table) - when using large dictionary program prints “mispelled words” and has to be closed with ctrl c

When running speller with the small dictionary and ralph.txt as the text, my program correctly outputs the misspelled words and outputs the statistics (i.e. time in load, number of words in dictionary ...
0
votes
1answer
89 views

Pset5 load function doesn't load any words

Still getting segmentation fault and have updated code several times. Here is my most recent iteration and have also attached copy of valgrind report. /** * Loads dictionary into memory. Returns ...
0
votes
1answer
127 views

pset5 load function has “expression result unused” errors

I think this relates to my understanding (or lack of) of pointers. I have 3 errors for the following code -- this is just inside my while statement. Both root and current are defined as nodes and ...
0
votes
1answer
32 views

Misspelled word not identified properly in check()

In my check function I keep getting true (word is in dictionary) for some words which I did not load into the dictionary. bool check(const char *word) { node *current = &root; // ...
0
votes
2answers
103 views

My unload only gets one free

I've rewritten my code a bunch of times and it clicks in my head...buuuuut it doesn't actually work. I'm not doing the actual cs50 problem because I prefer to start smaller then adapt to cs50. I'm ...
0
votes
1answer
169 views

Pset5 - thousands of errors using valgrind. Help?

I've successfully implemented the dictionary and it fully works (already submitted and got 100/100). But when I run valgrind I get9911215 errors from 6 contexts. I really don't know what that means or ...
0
votes
1answer
81 views

Seg fault in check function PSET5 Speller

I am extremely confused as to why after testing my functions 1 by 1, that my check function returns a seg fault. I understand it is when something is wrong with memory, but I can not seem to find the ...
0
votes
1answer
69 views

Segfault on unload. Pset5 Speller

Just got my speller working. Except for the unload func. I feel that idea is right, but maybe the implementation is wrong. Words are not that long, so i figured that recursive solution wouldn't result ...
0
votes
1answer
341 views

PSET5 speller (load) - stuck on understanding it's logic

I'm stuck on this part of the problem for weeks, it's killing me. If someone could please, please at least point me in the right direction. I know I'm asking a general question but I seriously don't ...
0
votes
1answer
83 views

Segmentation fault! when i execute the program it suffer segmentation fault but when i run debug50 everything is fine!

/** * Implements a dictionary's functionality. */ #include <stdbool.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include "dictionary.h" typedef struct ...
0
votes
1answer
358 views

I'm really having a hard time with speller! Gives me a seg. fault. Please, help!

This is my code for load and valgrind points at line 127 as the reason for the seg. falut. Please, can someone point out to me why. Thanks.`/** *Loads dictionary into memory. Returns true if ...
0
votes
1answer
365 views

Pset 5 Load Function

I'm having trouble with my load function... I had it working previously, but after changing some stuff and dealing with the check, I ran into this issue and can't seem to figure it out... Every time ...
0
votes
1answer
45 views

PSET5 *** Error in `/home/ubuntu/workspace/pset5/speller/speller': double free or corruption (!prev): 0x0000000000603250 ***

Upon writing unload, I get the following error *** Error in `/home/ubuntu/workspace/pset5/speller/speller': double free or corruption (!prev): 0x0000000000603250 *** In the GDB console, I get ...
0
votes
1answer
1k views

PSET 5 - Just trying to understand what valgrind is telling me

I've successfully completed my program, but since this is my first time working with malloc() and free(), I wanted to make sure that I understood what valgrind was giving me as feedback. So first off ...
0
votes
1answer
133 views

pset5 speller load, please let me know if this makes sense

I'm having a really hard time with pset5.. I think I 'vaguely' understand the flow from the walkthrough, but it's really difficult for me to implement it in code.. I tried to 'collage' every element ...
0
votes
1answer
600 views

'Initializer element is not a compile-time constant' error but no way around it

I'm currently on pset5 and am so close to finishing. All my load, check, word count and unload functions are fine, as far as I know but my problem lies in the declaration of this: //Define node data ...
0
votes
1answer
86 views

singly-linked list issues

this is not directly related to the problem set, but maybe somebody can help me out nevertheless. I'm trying to understand the singly-linked list and so I've attempted to write one on my own, based on ...
0
votes
1answer
121 views

handles possessives properly and substrings properly fail- pset5(trie)

bool check(const char *word) { int i; node *loader = root; for(int c = 0; word[c] != '\0'; c++) { if(isalpha(word[c])) { i = (tolower(word[c]) % 'a'); } if (word[c] ==...
0
votes
1answer
79 views

Problems printing trie to check load in Pset5 - edited

I'm trying to complete Pset5 using a trie. So far, I've written the code for load() and it seems to work (at least, my counter variable for the number of words goes to 2 when I try to load ...
0
votes
1answer
62 views

Check50 error specification?

So :) dictionary.c, dictionary.h, Makefile exist :( speller compiles \ expected output, not standard error of "dictionary.o: In function `check':\n/va..." The code is working (not as fast ...
0
votes
1answer
100 views

PSET5: Hash function and code not handling possessives and substrings

I am having a lot of problems with pset5. I have identified more than one issue with the code but I don’t know how to fix the issues. The first is from my hash function, which is featured below and I ...
0
votes
0answers
113 views

How can I write a recursive function if that function's parameter is void? - pset5 - unload

Per the specification, we are not allowed to alter the declarations of load, check, size, or unload in dictionary.c or dictionary.h. Yet in Zamyla's walkthrough for unload, if one implements with a ...
0
votes
1answer
122 views

stuck at last hurdle! pset5 speller

I've posted on this one before and got advice that has got me to almost finish this pset (thanks, blauelf!), but now I'm totally stuck. Everything seems to work except for I can't get the word from ...
0
votes
0answers
31 views

Need help with pset5 load of speller.c. Segmentation error [duplicate]

typedef struct node { char word[LENGTH+1]; struct node *next; }node; int *num; node *hashtable[26]; int hash(const char* word) { int n = tolower(word[0])-'a'; return n % 26; } bool load(...
0
votes
1answer
442 views

Speller Valgrind errors. Fixed but not sure if correct

I have managed to finish pset5 speller and attempted creating dictionaries with linked-list, hash tables and tries. They are all working successfully and if I create a hash table with 20,000 elements ...
0
votes
1answer
209 views

pset5 (check) - can't pass word to hash function - error with var type

I'm really struggling with this one! I've just about got through to the last section I have to complete and I have two issues that I know of (I can't get 'check' to work so I don't know if 'load' is ...
0
votes
2answers
97 views

Check function not working. Using a Hash Map to store the dictionary

I am trying to debug and understand which part of my code is causing check() not to work. It's possible that the code maybe more complicated than needed but I was going to refactor it once I had a ...
0
votes
1answer
65 views

pset5: Value of pointer changes during runtime in load()

For pset5 I am using trie as a data structure to load words into the memory and the small dictionary loads just fine but for the large dictionary I always get a segmentation fault while loading the ...
0
votes
1answer
91 views

Help with Check Function in Pset5

typedef struct node { bool is_word; struct node* children[27]; } node; node* root; bool freenode(node* crawler); bool is_word; int words; /** * Returns true if word is ...
0
votes
1answer
107 views

Pset5 distribution code

I'm in the middle of implementing Speller, I've just got the 'Load' to work in a separate test file. My question is how to insert the function into the distribution code? That is: How can I ...
0
votes
1answer
302 views

Submitting pset5 to the new CS50 2017 grade book

I had started pset5 before the introduction of the new course material for 2017 and the gradebook. The have finished the pset5 of 2016. My question is whether I can submit my pset5(2016) to the new ...
0
votes
1answer
103 views

pset5 works fine but doesn't pass check50

i have the following problem: After a few days of working on pset 5, I finally solved it, I tried it with different text and compare the results with the implementation of the staff and the output is ...
0
votes
1answer
85 views

PSET5 : My program outputs wrong number of misspelled words

#define MAXH 145709 int total_words = 0; typedef struct node { char word[LENGTH + 1]; struct node* next; }node; node *hashtable[MAXH]; // djb2 by Dan Bernstein unsigned long hash(unsigned ...
0
votes
1answer
81 views

load function in pset5 (segmentation fault)

These are my codes for the check and load functions. bool check(const char* word) { // TODO node* trav=root; char c; //char s[100]; //strcpy(s,word); for(int i=0;i<strlen(word);i++) {c=word[i]; ...
0
votes
0answers
126 views

pset5 load() and unload()

I need some help in spotting where is the problem in my load and unload functions and if the logic is correct. Also, whenever I execute valgrind and its telling me: definitely lost: 8,013,040 bytes in ...
0
votes
1answer
220 views

Pset5 - Implementing Load function - Help with calloc

I'm not sure I am using calloc correctly as it is my first time attempting after getting random seg faults using malloc. Anyway, after changing my code to use calloc instead of malloc, I am still ...
0
votes
1answer
55 views

Pset5 Load - Getting Seg Fault when setting is_word = true

bool load(const char* dictionary) { FILE* infile = fopen(dictionary, "r"); if (infile == NULL) { return false; fclose(infile); } node* root = malloc(sizeof(node)); node* new_node = root; if(...
0
votes
1answer
202 views

Pset5 Unload - Recursion with Tries - Fails Valgrind with apostrophes

I'm getting a strange problem in my unload() code, or more specifically the freeNode() recursive function that unload() calls. I think I have the recursive part of the function nailed; once free(...
0
votes
1answer
103 views

Trouble with Substrings in Check in Pset5

I have used a trie structure to implement my dictionary in pset5 and I believe my load() function is operating correctly, however I seem to be having trouble with checking substrings in the check() ...
0
votes
0answers
54 views

pset5 unload segmentation fault

I am getting seg fault. I am not being able to determine error by debugger. bool unload(wordtree* del) { if(del==NULL) return true; for(int i=0;i<27;i++) { if(del->ptr[i]!=NULL) { ...
0
votes
1answer
374 views

CS50 Pset5 Speller Trie Reports All Words As Misspelled, Check Not Working

My Speller Trie Code for CS50 reports all words as misspelled. I need some help please. It will compile and run. Valgrind doesn't report any memory leaks or errors. I don't think that the "check" ...
0
votes
1answer
60 views

Pset5 problem with load function : Keeps getting segmentation fault

I have been working on pset5 and i keep getting segmentation fault while trying to implement 'load' function. I cannot really see where is the problem. Any help will be really appreciated! Here's my ...
0
votes
1answer
152 views

CS50 pset5 unload trie segmentation fault

I am having problems with implementing unload. load works perfectly and I can use the check function. I have tried many ways of changing my code but it only creates an infinite loop and I have no idea ...
0
votes
1answer
59 views

pset5 can't see the issue with my code

completely stuck in pset5 for so long... I rewrite my code several times and try to find any info from anywhere. But now seems still not working. compile speller with no error. when I try to run ./...
0
votes
1answer
231 views

Having trouble running speller.c

I have finished writing my code for pset5 and it compiles. Now I want to try and run it, but apparently, I can't figure out how to do so. What does "./speller [dictionary] text" mean? I have tried ...
0
votes
2answers
369 views

valgrind check have error;segmentation fault when run speller

Below is the message returned from valgrind check. ==6239== Invalid write of size 8 ==6239== at 0x401308: load (dictionary.c:109) ==6239== by 0x4009BD: main (speller.c:45) ==6239== Address ...
0
votes
1answer
297 views

pset5 load with a trie Killed

I'm having a lot of trouble with my pset5. I'm attempting to use a trie to load the dictionary. It will compile but nothing really more than that. when using gdb, the program shows "Killed" in the ...
0
votes
1answer
417 views

PSET5 Speller problem with apostrophes

I haven't been able to figure out why my code recognizes every word with apostrophes as a misspelled word. I was hoping someone can help me spot any problems with my code. Trying not to break the ...
0
votes
1answer
130 views

Pset 5 - Understanding problem with the code of speller.c - Checking part

I could not found any explanation about the checking part of speller.c and this bothers me a bit not to understand it. If we read the code below, this is what I understand: Check if c is an ...

1
18 19
20
21 22
24