Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in trie solution? #238

Closed
codescv opened this issue Aug 20, 2018 · 0 comments
Closed

Bug in trie solution? #238

codescv opened this issue Aug 20, 2018 · 0 comments

Comments

@codescv
Copy link

codescv commented Aug 20, 2018

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.

@codescv codescv closed this as completed Aug 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant