Deletion in a Trie
After insertion and search, let's figure out the logic behind deletion in tries.
Deleting a Word in a Trie #
While deleting a node, we need to make sure that the node we are trying to delete does not have any further child branches. If there are no branches, we can easily remove the node.
However, if the node contains child branches, this opens up a few scenarios which we will cover below.
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.