Questions tagged [trie]

The tag has no usage guidance.

33 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
1answer
531 views

Pset5 Speller load() function completely stuck (trie)

I am completely stuck on pset5 load() function, have no idea where to go. Can someone please guide me in the right direction? Here is my code: bool load(const char* dictionary) { // TODO FILE* file = ...
1
vote
0answers
2k views

Valgrind says "Invalid read of size 4" while freeing memory recursively in a trie

My PSET "mispelling" works fine and contains no memory leak but when I run the program with Valgrind it says Invalid read of size 4. My unload function calls a deleteTrie function which looks like ...
1
vote
0answers
106 views

Is hash table a type of dictionary?

In week 7 shorts for trie it is said that "a dictionary is a type of data structure that maps a key (usually string) to value". So is hash table considered a dictionary too?
0
votes
1answer
25 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
41 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
47 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
65 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
66 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
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
351 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
109 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
2answers
74 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
302 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
38 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
282 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
485 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
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
62 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
203 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
104 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
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
93 views

Logic Error in speller.c - Can't open text file and also have doubts about load() and check()

I wrote check() and then I tried to test speller with dictionary/small and a text file I'd written myself, but the text file couldn't be opened. Is there a problem with the way I implemented load() ...
0
votes
1answer
47 views

pset5 check fails possessives and substrings

Ok, so I'm stuck... I finally (hopefully?) got load to work correctly, ie no leaks or errors with valgrind, but now check is giving me a hard time. I only have 135 words misspelled; and it I fails ...
0
votes
1answer
136 views

Pset5 Unload will not compile

I am still stuck on pset5 speller.c. I am trying to implement unload via tries. I have tried several different codes which were not giving the correct output, but the last one I did could not even ...
0
votes
1answer
108 views

Pset 5 Dictionary TRIE Segfault

I know posting the while code is not cool, but I frankly can't figure out what is wrong anymore. I should have done this with something easier than trie-structure, but since it is close to done I'd ...
0
votes
1answer
115 views

recursive trie generation segfaultin

Halp, I'm trying to implement a clever and zippy recursive trie makin function for load() in pset5, but my program's exploding when I trie, and I'm struggling to educe the problem (probably an ...
0
votes
1answer
188 views

PSET5 Dictionary.c issues with implementing Load using trie

I've written some lines of code to implement the trie alogorithm for loading the dictionary. I'm facing the following issue: Compiling speller.c is giving me some errors, one of which is the below: ...
0
votes
2answers
80 views

pset5 check wrong if condition

This is how code looks before functions in dictionary.c typedef struct node { bool is_word; struct node* children[27]; } node; node* root; The load function works fine, but when the program ...
0
votes
0answers
100 views

pset5 load function mallocs more new then i expected, am i building the trie wrong?

With the answer and tips from Cliff B i've managed to stop segfaults and loosing data in the memory, but still unsure about trie implementation. Here's the current code: bool load(const char* ...
0
votes
1answer
726 views

pset5 trie load function killed with large dictionary

This has been bugging me for weeks. The program seems to run OK with small dictionaries, but gets killed with medium size - after around 95,000 words - it varies. LETTERS is set to 27. Any help would ...
0
votes
0answers
104 views

a simple linked-list try

First of all, i need to say that i am just trying to check my code working or not. For the following code, i used a so-called small dictionary which only includes the words "caterpillar" and "cat". ...
0
votes
1answer
548 views

Insert nodes into trie for Load

I'm not quite sure how to iterate through a string and malloc a new node to properly insert each letter into a trie for pset5/6 (2014/15). Here is the relevant code that I've come up with so far, ...
0
votes
1answer
232 views

How do I load words in speller that are mixed letters and numbers?

I'm struggling with pset 6 (quite difficult logical and implementation wise, but I like this level of difficulty and this challenge). I'm implementing load and I just found out that I'm 34 words off ...