I want to create a trie for this pset and need a nudge in the right direction. I have created a struct node and malloc space for the 'root' struct. Now I think I want to populate each node in the root struct with a letter of the alphabet and the apostrophe character. My question is, how can one accomplish this? My first thought was to use a for loop. Also, am I supposed to set each bool value to false initially? Finally, why is '/'' used for apostrophe?

  • Alright, I just figured out that you don't have to populate the node with the letters of the alphabet in order (like in every example presented in class videos) but that you populate it with letters on the fly as you read words from the dictionary. – Flesheaters Nov 8 '16 at 5:12

so there are a bunch of ways to go through this, but I'd watch the walkthroughs and search CS50 exchange here for similar questions. Both of those provide a way of getting deeper into this question. Once you have an approach, I'd be happy to help with implementation.

For the bool values, you will want to set them to false, otherwise every time you hit the end of an input, if that character set is in your trie it will come back as a word whether or not it is. So if you have melon in you dictionary and it searches the world 'Mel', it will return true even if 'Mel' isn't in your dictionary.

Finally \ is the escape character as in \0 for the null terminator \' just prevents C from reading the single quote as the ending of a string.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .