Deletion in a Trie
After insertion and search, Figure out the logic behind deletion in tries.
Deleting a word in a Trie
While deleting a node, you need to make sure that the node that you are trying to delete does not have any further child branches. If there are no branches, then you can easily remove the node.
However, if the node contains child branches, this opens up a few scenarios which will be covered below.
Case 1: Word with no suffix or prefix
If the word to be deleted has no suffix or prefix and all the character nodes of this word do not have any other children, then you will delete all these ...