Shanil P.

asked • 06/16/20

File Compression and multi-dimensional arrays

Compression Algorithm:

One method of compressing a file is to recognize repeated digits and replace the runs of

repetition with a number representing the repetition length. For instance for a line in you file

such as ;

0110000000000110

Can be represented with the line:

1 2 10 2 1

Because there is 1 zero, 2 ones, 10 zeros, 2 ones and 1 zero. It is already understood that only

zeros and ones appear and that zeros apper first in a given line. Thus storing the new line of

data is much shorter (5 numbers) than the original line (16 numbers)

To decompress the encoded file you can follow the reverse implementation of the method

stated above, for example for the encoded data:

4 2 4 2 4

The decompressed data is:

0000110000110000

1 Expert Answer

By:

Patrick B. answered • 06/16/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.