It takes Decompressed words as input and return a Compressed file as output by Calling encode(). When it is given Compressed words file as input, it calls decode() and returns decompressed file of words.
The algorithm works on the principle of encoding words by:
-
Finding the prefix that exactly exists in the previous word.
-
Counting it's length
-
Writing the length and then the remaining word.
-
The file is decoded on the basis of this prefix length.
I run the python file using the tool insomnia.