Skip to content

Missing conditional check? #2

Open
@aryamansharda

Description

@aryamansharda

Thanks for this great open source resource! I think I may have noticed a potential bug, however. In the Decoder, the user provides:

input_file, n = argv[1:]            
maximum_table_size = pow(2,int(n))

But, they're not used anywhere in the following code. I believe the following change is in order:

if not(len(string) == 0):
        dictionary[next_code] = string + (dictionary[code][0])
        next_code += 1
    string = dictionary[code]

Should be:

 if not(len(phrase) == 0):
            if(len(dictionary) <= maximum_table_size):
                dictionary[next_code] = phrase + (dictionary[code][0])
                next_code += 1
        phrase = dictionary[code]

I ran the code with this change and it continued to work. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions