Wai
Wai

Reputation: 113

By using modified RLE, there must at least one "compressed" file larger than original one?

I have read this.

The mathmatical proof shown that for all lossless algorithms, there will be at least one "compressed" file getting larger than before.

For RLE, the compressed text file will be larger if all characters are different.

e.g. ABC -> 1A1B1C

But if i modified the rule of RLE:

(1) For 1,2 length characters, no number will be added

e.g. ABCCDDDEFFFF -> ABCC3DE4F

It seems okay and no compressed file will be getting larger. However, it contradicts the mathematical proof.

Upvotes: 0

Views: 63

Answers (1)

MSalters
MSalters

Reputation: 180010

You fail to support decompression, because your compression is not unique. The problem is that your input may contain numbers as well. Now the input "1A" in RLE transforms to "11A" and back to 1A. In your scheme, "1A" and "A" both compress to "1A".

Upvotes: 1

Related Questions