Question: To implement the compression algorithm that matches the decompression algorithm from Program from Program 1 To use file I/O in C++ (open, read a char,

  1. To implement the compression algorithm that matches the decompression algorithm from Program from Program 1
  2. To use file I/O in C++ (open, read a char, test for eof).
  3. To use an acceptable coding style: no goto, no global variables, proper indentation, and reasonable names.
  4. To understand and use a type cast to create a 1-byte integer

1.1Review: Run Length Compression

This algorithm is effective on text or binary files that have the same byte repeated over and over.Think of a file containing a table of numbers:it has lots of consecutive space characters, and may havea repeated filler character, such as a '.' .

In this scheme, any "run" of the same character (4 or more identical consecutive bytes) is replaced by a triplet of bytes, consisting of

  1. An escape character. We will use 0x7f, which is sometimes called "esc". It is a non-printing ASCII character
  2. The letter that has been repeated
  3. A 1-byte count = the number of repetitions

To make this work, any esc character, or run of them, that occurs in the input mustalsobe replaced by a triplet: esc esc count .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!