python implementation of patricia tries

后端 未结 1 935
孤街浪徒
孤街浪徒 2021-02-01 11:04

Looking around for python implementations of tries just so that I can understand what they are and how they work, I came across Justin Peel\'s patricia trie and found it very in

相关标签:
1条回答
  • 2021-02-01 11:52

    I believe the bug is in the following snippet of the code you're looking at:

           if w.startswith(node[0][:wlen-i],i):
                if wlen - i > len(node[0]):
                    i += len(node[0])
                    d = node[1]
                return True
    

    it should actually be:

           if w.startswith(node[0][:wlen-i],i):
                if wlen - i > len(node[0]):
                    i += len(node[0])
                    d = node[1]
                else:
                    return True
    
    0 讨论(0)
提交回复
热议问题