1

I think I understand how the children-nodes of a trie are supposed to work. But if the dictionary contains one-letter words like "a" and "I", what should the boolean-data value of the root node be? If it's FALSE, doesn't that mean the checker will mark one-word letters as misspelled? And if it's TRUE, how does the checker know which single letters are one-letter words as opposed to just single letters?

1 Answer 1

2

The trie starts at one root node. This node will always have the is_word bool as false because the root node doesn't actually represent a letter. For a one letter word, say a, you would first move one level into the tree, as in root->children[0] before setting that node's is_word to true. (a two letter word, like ad, would traverse the path of root->children[0]->children[3]->is_word = true.)

So, no matter the word, the root node represents a word of 0 length and will always have is_word = false.

If you're using a different design, such as using an array of pointers for the first letter, then it becomes dependent on your design.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1

You must log in to answer this question.

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