Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create a program in c + + that can compress and decompress text files without losing any information. The text files only contain lowercase letters,

create a program in c++ that can compress and decompress text files without losing any information. The text files only contain lowercase letters, numbers, and some special characters like spaces, tabs, and punctuation.
Objective: Create a program that can make text files smaller without losing any information. This process is called compression. You should also be able to reverse this process, which is called decompression.
Input Parameters: When running the program, you'll provide two main things:
The method (whether you want to compress or decompress)
The file you want to compress or decompress
Optionally, you can provide the output file name, or the program will choose a default name.
Supported Characters: The text files only contain lowercase letters (a to z), numbers (0 to 9), and some special characters like spaces, tabs, and common punctuation marks (like periods and commas).
Compression Method: The program should choose the best method to make the file smaller without losing any information.
create a program that can effectively compress and decompress text files while following the specified guidelines and requirements
Objective: The objective of Task 1 is to implement a compression method that reduces the size of the text files. In this method, each character is represented using only 6 bits instead of the usual 8 bits. This means that the size of the file will be reduced because fewer bits are needed to represent each character.
Character Representation: Since there are more than 32 but less than 63 characters, 6 bits are sufficient to represent all characters. Each character is replaced by a 6-bit representation, and these 6-bit representations are concatenated together. If the total number of bits is not divisible by 8, the remaining bits are filled with zeros.
Handling Ambiguity: There's a potential ambiguity when the last 6-bit word extends into the next byte by 2 bits, leaving exactly 6 bits remaining. To resolve this, the encoding starts with a specific bit pattern (000001) instead of all zeros. This ensures that if six zeros occur in a row, it's not interpreted as part of the last character.
Encoding Scheme: Characters are represented using bit patterns in ascending order. For example, 'a' is represented by the bit pattern 000001,'b' by 000010, and so on.
Implementation Details: If you choose to use a vector to implement this procedure, you'll learn how to handle bit sequences effectively.
Flags: When compressing, use the -a flag, and when decompressing, use the -b flag. If the output file name is not specified, append .kompein for compression and use out.txt for decompression.
Error Handling: If the input is not in the expected format, the program should abort and display an error message.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions