Questions tagged [speller]

speller.c is one of the files that make up Problem Set 5, but it is already written by CS50 Staff and you may not alter it! Instead, you must implement your solution by altering three other component files: dictionary.c, dictionary.h, and Makefile.

Filter by
Sorted by
Tagged with
9
votes
3answers
959 views

pset4 speller - can't pass valgrind test - 32 bytes still reachable

Can't pass valgrind test on pset4 speller (hashtable). The speller works perfectly but, I'm getting this message from valgrind: ==3911== ==3911== HEAP SUMMARY: ==3911== in use at exit: 32 bytes ...
1
vote
1answer
333 views

pset5:(speller) Check function does not correctly identify misspelled words

/** * Implements a dictionary's functionality. */ #include <stdbool.h> #include "dictionary.h" #include<string.h> #include <stdio.h> #include <stdlib.h> #include<ctype.h&...
2
votes
2answers
5k views

pset5 speller.c check

Hi I'm tackling CS50's pset5. I am trying to implement speller and I got stuck on check part. I implemented load via hashtables and whole dictionary loads up correctly,when I'm using smaller text ...
0
votes
1answer
161 views

CS50 PSET5 Memory Leak

I have spent more than 30 hours on this problem set and I am still struggling. At first, my program compiled but did not run, due to a segmentation fault. I finally fixed it and everything works fine, ...
0
votes
1answer
82 views

Load code pset5, speller.c. Segmentation error

bool load(const char *dictionary) { FILE *dic=fopen(dictionary, "r"); node *hashtable[26]; int num=0; char word[LENGTH+1]; while(fscanf(dic,"%s", word)!=EOF) { node *new_node=malloc(sizeof(node)...
0
votes
1answer
2k views

How to make the check function faster?

It seems to be taking too much more time comparing to staff's implementation. The other 3 functions are average, though. dictionary.c: https://gist.github.com/9dcb901f2007d09ae1c9c4fa934f13df Mine: ...
0
votes
1answer
169 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
1answer
3k views

Speller Unload Trie with Recursion

node* root; bool unload(void) { freenodes(root); return true; } freenodes function(node* path) { loop over all nodes { if node is not null (path -> children[i]) ...
4
votes
2answers
5k views

Conditional jump or move depends on uninitialised value(s)

I just finish debugging my code for pset5 dictionary.c, It's working correctly, It passed check50 too. Now the problem I am encountering is in valgrind my heap is all freed, But wherever in ...
2
votes
1answer
346 views

CS50 PSET5 Memory Leak (updated)

I had posted a question here two days ago regarding memory leak in problem set 5 and haven't had it resolved yet. Please refer to my question, available here: CS50 PSET5 Memory Leak (please note that ...
1
vote
1answer
630 views

pset5 speller.c with hashtable errors and seg fault

this is my code so far for pset5. I would appreciate giving me hints about my erros. I also get a segmentation fault. thanks. when I implemented load and check only, it seemed to load the text and ...
1
vote
1answer
297 views

pset5 unload double free or corruption

* Error in `/home/jharvard/Dropbox/pset5/speller': double free or corruption (top): 0x0804c698 * If I set unload to always return true, load/check work perfectly. Valgrind gives me a lot of invalid ...
0
votes
2answers
4k views

PSET5 Speller hash function

I have been working on the speller problem in pset5 for a while now, and I am not able to figure out the problem in my hash function: unsigned int hash(const char* word) { int M = 1000000001; ...
0
votes
1answer
69 views

can I just return trav->is_word from check?

I've been struggling terribly w/speller. Most recently the check function. I'm troubled by how convoluted my code looks because I see it as indicative of convoluted logic. I most recently generated a ...
0
votes
1answer
135 views

Memory leaks in Speller

My program passes all tests except the valgrind check. I tried to find the cause of errors, but valgrind is too 'obscure' for me yet, I don't know what to do. I guess some memory isn't freed, but I ...
0
votes
1answer
146 views

dictionary.c not iterating through the linked list, if the hash exists it always returns true

Trying to figure out a bug in my dictionary.c code. Please bear with me as I try to explain the bug. I've been using the debugger, and it seems that anytime there is a collision in my hash table, ...
0
votes
1answer
105 views

Stuck on the unload() function. Possibly wrong logic used on load() and check() using tries

I am using tries to complete the spellcheck but I just can't keep up with the logic. I've implemented load() and check() as much as I could but I'm sure it has some logic flaw. The unload() function ...
0
votes
1answer
45 views

Help with unloading my dic

I have been trying speller for far too long now and need help with unloading the dictionary. This is the code I have now // Unloads dictionary from memory, returning true if successful else false bool ...
0
votes
1answer
211 views

56 Bytes of leaked memory in speller.c pset5

56 Byte memory leak - not sure where it is coming from. Valgrind points to the malloc'd space for nodnew in the load function - in my first version, I created the pointer nodenew and malloc'd the ...
0
votes
1answer
29 views

Output hangs midway in speller

I've completed writing my code in dictionary.c . When I comepile it, it shows no errors, and no memory leaks occur in valgrind. But when I run the code, it hangs after displaying MISSPELLED WORDS // ...
0
votes
1answer
436 views

Where are the dictionaries for speller?

When I run speller.c it says it could not load dictionary. I can't find the dictionaries anywhere in the appliance. Home directory only has jharvard in it and when I put gedit ~cs50/pset6/dictionaries/...
0
votes
1answer
141 views

CS50 PSET5 Memory Leak (updated2)

I had posted two questions regarding memory leak in Problem Set 5, available at CS50 PSET5 Memory Leak and CS50 PSET5 Memory Leak (updated). I got amazing feedback from different people (and I ...
0
votes
2answers
295 views

Pset5 - Problem with hash table load(), malloc, and segmentation-fault

I am having problem with the load function. When I run: valgrind --leak-check=full ./speller texts/austinpowers.txt it gives me the following report (I am using the small dictionary to test my code) ...
0
votes
1answer
171 views

Pset5: Check returns all as misspelled (trie)

I can't, for the life of me, figure out why my check function doesn't work properly. I have triple-checked my load() every way I know how and believe the data structure is properly setup. Why doesn't ...