![]() |
VOOZH | about |
In the previous post on trie we have described how to insert and search a node in trie. Here is an algorithm how to delete a node from trie.
During delete operation we delete the key in bottom up manner using recursion. The following are possible conditions when deleting key from trie,
The below code presents algorithm to implement above conditions.
Yes No Yes
Time Complexity: The time complexity of the deletion operation is O(n) where n is the key length.
Auxiliary Space: O(n) due to recursive call stack, where n is the key length.