So in theory the concept of a trie makes a lot of sense, but I'm really missing something when it comes to putting it down into code. Any help would be soooo greatly appreciated. I've scoured the internet for help but still missing a few connections. Ok... Here's what i'm getting... or think i am. Sorry this is gonna be long...
First off children[0] doesnt hold any actual value at that index right? its literally just a pointer. So 'a' doesnt actually exist anywhere other than that its essentially children[a]?
You create and malloc a root node, the is_word bool is false and the children pointer isnt pointing anywhere.
Then you create a new node that equals the root...
Then you iterate over the word to input the characters one at a time...
If the character is a letter or ' then you create/malloc a new node and the is_word is still set to false.
When you reach the last letter of the word you change is_word to true... that is essentially adding \0 right? (Also, instead of checking for NULL would saying if i == length of the word work?)
That potentially takes care of one word in the trie... I cant figure out how then to start another one. is it literally the same thing? and the way you find different words is just by seeing if the index of children is null? if so there's no letter if not then keep checking for null until you find is_word = true?
Typing this out helped a bit but still confusing.. Thanks for the help!