in the delete method of graphs_trees/trie/trie_solution.ipynb:
while parent is not None:
As we are propagating the delete up the
# parents, if this node has children, stop
# here to prevent orphaning its children.
# Or
# if this node is a terminating node that is
# not the terminating node of the input word,
# stop to prevent removing the associated word.
if node.children or node.terminates:
return
del parent.children[node.key]
node = parent
parent = parent.parent
When you traverse from child to parent, the parent will always at least contain one child. Thus the parent.children[node.key] will never be deleted.
in the delete method of graphs_trees/trie/trie_solution.ipynb:
while parent is not None:
As we are propagating the delete up the
When you traverse from child to parent, the parent will always at least contain one child. Thus the parent.children[node.key] will never be deleted.