Answered step by step
Verified Expert Solution
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 to 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 is to implement a compression method that reduces the size of the text files. In this method, each character is represented using only bits instead of the usual 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 but less than characters, bits are sufficient to represent all characters. Each character is replaced by a bit representation, and these bit representations are concatenated together. If the total number of bits is not divisible by the remaining bits are filled with zeros.
Handling Ambiguity: There's a potential ambiguity when the last bit word extends into the next byte by bits, leaving exactly bits remaining. To resolve this, the encoding starts with a specific bit pattern 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 b by 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started