A prefix can also be a stored word in its own right, and autocomplete should offer it as one of its own completions. Today you confirm the exact case where the prefix node is marked end-of-word.
Include the prefix itself in its completions when the prefix is a stored word.
When you call Completions("car") on a trie that stored car, the subtree walk
starts at the car node - and the very first thing it does is check that node’s
end flag. Because car was stored, end is true and the empty suffix is
recorded, producing car itself. Then it descends into the d and e children
for card and care.
The ordering falls out naturally: the empty suffix "" sorts before any
non-empty one, so the prefix-word always leads its own completions -
car, then card, then care. This matters for real autocomplete: if you have
typed a complete word that is also the start of longer ones, the engine should
still offer the word you have already typed as a valid choice, not silently drop
it in favour of the longer completions.
// No new code if lesson 8 is right: the walk starts AT the prefix node,// and that node's own end flag is checked first (suffix == ""), so a prefix// that is a word is emitted as prefix+"" before any child is visited.// This lesson pins that behavior with a test.