开发者

help with huffman code

ok I have my huffman class which seem to be working fine. however when I am trying to make my binary tree I keep on getting an error message saying that ''the global name encoding is not defined'' when the name of my function 开发者_高级运维is encoding. Can someone please tell me why? below is my code. Thank you

def get_encoding(self):
        # Huff is a previously defined function that generates the tree 
        node=self.Huff()
        dic={}
        if node.char:
            if not self:
                dic[node.char]='0'
            else:
                dic[node.char]=self
        else:
               encoding(self+'0',node.left)
               encoding(self+'1',node.right)


It looks like you're trying to make a recursive call to get_encoding, but the signature differs since the definition doesn't take 2 parameters. There may also be a problem with you trying to do self+'0' and self+'1'.


The name of your function is not encoding, it's get_encoding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜