Questions tagged [trie]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
25 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
0answers
16 views

trie speller always leaves last word out for check()

My check function seems to find all incorrect words except the last work in the text. I've tried to move around my is_word==true statement to check if its because I'm not checking that the word ...
0
votes
1answer
16 views

trie speller check() function no mispellings

working on check() function and my trie data type seems to load ok with the full dictionary but check is unable to find any mispellings for a text file. I beleive I'm not correctly returning false ...
0
votes
0answers
19 views

Why is my program missing misspelled words? PSET4, Speller(trie)

I am working on pset4, implementing a trie and asked a previous question then went back and corrected my mistake. Now, when I run my program, I get fewer words misspelled than the staff's solution ...
0
votes
1answer
60 views

Pset4 Speller, Trie. Why are all words misspelled?

first time poster and new beginner. I realize this question has been asked numerous times among different forums, but still after looking at other's code, I simply can't figure it out. I have ran my ...
0
votes
1answer
29 views

pset4 speller trie segmentation fault

I am doing the trie version of speller in pset4 and keep getting a segmentation fault. I have run my code on short dictionaries and short text files and it seems to work just fine but when I try ...
0
votes
1answer
16 views

Segmentation fault, speller trie pset 4

I'm getting a segmentation fault where i set node *new = malloc(sizeof(node)) I don't understand why I'm getting this fault, i am just allocating new untouched memory with malloc. // Implements a ...
0
votes
1answer
24 views

trie speller works on custom dict but misses mispellings on large dictionary

So my speller works fine with a custom dict, but not with the large dict. This is my code in dictionary.c (haven't modified other files): // Implements a dictionary's functionality #include <...
0
votes
1answer
55 views

Stuck with Unload using trie

I could not unload the dictionary, and still don't understand why. It seems that it is not freeing what I think. I would really appreciate some help, here is my code: // Unloads dictionary from ...
0
votes
1answer
46 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
0answers
38 views

Dictionary load in pset4 -> Trie Implementation

I don't know if this is a problem others have had? Having some issues with the dictionary load function in pset4. I decided to implement a trie and thru following debug50, I can see that it is ...
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
28 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
29 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
0answers
45 views

Problem with pset4 2019 trie dictionary

I'm having problems with my trie dictionary.c file, if I try to run the whole program normally or through gdb, I'm getting no errors whatsoever and I'm getting the right answers. Tho, when I try to ...
0
votes
1answer
37 views

valgrind() causing IDE to shut down

working on pset4 speller via trie. I AM AWARE OF THE CLANG BUG. According to one of the answers in the original question i removed the -fsanitize flag and ran valgrind() on it while using a small ...
0
votes
1answer
188 views

pset4/speller/trie

Since there was no help I repeat my question...I have a weird problem in speller using trie.... when I tested it on my Ubuntu visual studio code it works and compiles when using a dictionary of 4 ...
0
votes
1answer
48 views

cs50 pset4 speller trie word too long “index 46 out of bounds for type 'char [46]'”. Isn't that handled by the code already written?

My code is giving all the right answers (lalaland.txt), but valgrind says: ==9947== dictionary.c:69:25: runtime error: index 46 out of bounds for type 'char [46]' (and I printf the problem - too ...
0
votes
0answers
51 views

Speller Trie not reading apostrophes?

For a reason I have fruitlessly tried over and over to work out, my trie code, while functioning well in all other aspects, either is not reading apostrophes into its dictionary or is not properly ...
0
votes
1answer
111 views

Pset 4: Speller (trie) - misspelled words

I'm stuck. In Speller, implemented with trie, I get more misspelled words than I should. The number of words loaded into the dictionary is correct, there are no leaks or error messages. When checking ...
1
vote
1answer
48 views

Pset5— program isn't checking all words, marks all words it checks as misspelled

I've been running the code with the small dictionary and a sample text of "cat hgsgk caterpillar", so the code should theoretically return a wordcount of 3, and hgsgk as the only misspelled word. ...
0
votes
1answer
47 views

pset4 speller trie - Code passes check50 but the output does not match the staff output

Check50 returns all happy faces but my program doesn't find as many mispelled words as it should. I'm not sure if the problem is my check function or my load function I tried checking witih debug50 ...
0
votes
1answer
185 views

PSET5 speller - I cannot understand tries at all

I am so completely lost. I completed PSET5 with a hash table, and the concept of hash tables makes sense to me. Now I am attempting to do it with a trie, and I am just so confused I don't even know ...
0
votes
1answer
57 views

cs50 speller trie: (in c language) can't figure out what i'm doing wrong with load. Seems to work but seems non-existent in other functions

sorry if I am asking the question in a wrong way or my code is too messy I am knew here. My problem is that it looks like load works and the dictionary is loaded into the trie but check and unload ...
1
vote
1answer
412 views

Speller(trie) / my code can't handle most basic words and substrings properly

I need help. When I check my codes through check50, I got a result like below :) dictionary.c and dictionary.h exist :) speller compiles :( handles most basic words properly expected "...
1
vote
1answer
113 views

pset4 - speller trie load - ptr not linking up

I have been stuck on the load part of the speller exercise for the tries table. I have gone through a lot of the existing questions and come to the following code: while (fscanf(file, "%s", word) != ...
0
votes
1answer
58 views

Pset5 load - Stuck in infinite nested while loop

I have been working on this problem set for some time. At the moment I am stuck at figuring out why the nested while loop is infinite despite of the fact that there is an fgetc() function that runs ...
0
votes
1answer
121 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
116 views

pset5 “words in dictionary” is 0

I'm not having much luck troubleshooting my speller code. It returns the correct misspelled words and words in text, but words in dictionary returns as 0. I ran valgrind and it said there is a leak in ...
1
vote
1answer
238 views

Pset5: Need Help with Check

My 'Check' function outputs words that are not misspelled and skips over the ones that actually are. It also doubles the words that it outputs. For instance, in a sentence "There was once a catapillar"...
0
votes
1answer
131 views

Pset5 Speller : Check gives segmentation fault : Tries

I am not getting where the segmentation fault is happening. // Implements a dictionary's functionality #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <...
0
votes
1answer
75 views

PSET 5 - how to use the least memory - the magic trie sauce

Ive successfully finished the pset, and am mid-tier on the Big Board - but I have become transfixed with reducing space/time complexity. The only secret sauce Ive been able to glean is that those ...
0
votes
1answer
79 views

pset5 speller seems to work fine at first, but stops working halfway

I have been working on this error for couple days, but still cannot figure out what the problem is. The program compiles and finds the misspelled words in the beginning, but after printing out about 3/...
0
votes
1answer
112 views

Pset5 unload: how can I update Trie's data inside a recursive function?

few people suggested to use a recursive method of unloading a Trie data structure, but I am struggling with it a bit. I am stuck on the part on how can I update the root node ( the main node which ...
0
votes
1answer
48 views

speller compiles but horribly fails check50

i genuinely have no idea where the problem lies so any help would be appreciated, thanks in advance. check function bool check(const char *word) { trav = root; int index = 0; for (int ...
0
votes
1answer
299 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
326 views

Pset5: What To Do

I would really appreciate help with Pset5 load. I initially wanted to implement a hashtable into my code but after hours of looking I couldn't find a good hashtable from the internet that I wanted to ...
0
votes
1answer
1k views

PSET5: Hash function returning collisions

Looking for advice on hash functions and strings. For PSET5, I decided to implement a trie but instead of storing [a - z] in each node, only storing [0 - 9]. For this to work, I hashed the words and ...
0
votes
1answer
100 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
116 views

I don't understand how a trie works. Please help

I am on pset5 and have completed the check and load functions. However, with the unload function I am having trouble understanding how to visualize it. As suggested in the walkthrough, I tried to ...
0
votes
1answer
194 views

Pset5 trie unload -recursive function does not free memory

im close to finish this problem set , but i cannot figure out the working recursive function, especially if backtracking may work in this form of implementation: void rec_unload(node *trv) { for(...
0
votes
2answers
64 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
213 views

Pset 5 - struggling to understand how to check for NULL in a trie

I'm sure my code has a ton of errors, but I'm mostly on line 61 right now. I'm getting this error: dictionary.c:61:25: error: invalid operands to binary expression ('struct node' and 'void *') ...
0
votes
1answer
22 views

sizeof() syntax error with node pointer

Is there something wrong with my syntax? Won't compile, apparently because of line: sizeof(node->sprouts) / sizeof(node) above node defined as follows: typedef struct node { bool is_word; struct ...
0
votes
1answer
282 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
56 views

pset5, don't know if [load] successfully, [check] return no misspelled

could you please teach me how to make sure if i load the dictionary successfully. when i run check, no word misspelled.. Thank you. typedef struct node { bool is_word; struct node *children[27]; } ...
0
votes
1answer
602 views

Need help with check in speller (trie)

Stuck on speller, especially check, but load has some problems too. I am using a trie, but I kind of regret choosing it, because it has been very tough. I believe my problem is with the use of *next ...
0
votes
1answer
36 views

Want to ask about a trie

I have referred various resources but still have a doubt regarding tries. Do characters actually get stored in a trie? ( i think the answer is no) Suppose we are storing CAT and CAB in a trie. We ...
0
votes
1answer
106 views

pset5 2017 unload() trie segmentation fault and undefined behavior

Having a lot of trouble with unload(). I've scrapped nearly working functions several times just in the hopes that starting over will fix things. I cannot figure out why my code keeps leading to the ...
0
votes
1answer
74 views

pset5 speller unload - node allocation quirk

Most of this pset5 has gone smoothly, but unload() has caused me problems. When I'm navigating down my data structure (trie) to locate a node with all NULL children, the last index has a memory ...