Reference no: EM133634971
Programming Concepts
Assignment - Compression is used to reduce resource usage, such as data storage space or transmission capacity. Compression can be either lossy or lossless. Lossless compression reduces bits by identifying and eliminating statistical redundancy. No information is lost in lossless compression. Lossy compression reduces bits by identifying unnecessary information and removing it. The process of reducing the size of a data file is referred to as data compression.
In this assignment we are going to create our own simple lossless data compression algorithm and implement it as a C++ class. In this assignment you will feed your class an input file that contains various words. Your class will read these words, keep track of when it finds a new word that it did not encounter previously and assign a number to that word. Your program will write an output file that contains the compressed data which will be the numbers that are associated with the words that were in the input file.
For example, if my input file had the following text: "test this file test test test", then the output file might look like this: "12 31 1 1". In this case my program would have associated the number "1" with the word "test", the number "2" with the word "this" and "3" with the word "file". To make this assignment easier, we will only deal with words and not punctuation or newlines. You can also treat the word "test" and "Test" as the same word or treat them as separate words. It is ok to limit your program to a set number of words that it can store (try to store at least 1000 unique words). At the end of your output file you must print out a list of each word and the associated number that your program used to compress the data so that we could decompress and read the data.
In your program you must use file input and output. You must use object oriented design to write your code in C++. You must use exception handling. (Use try and catch statements.) You must create at least 3 different test input files. You must create a header file (.h) and separate your class source code file (.cpp) from your main source code file. (You should turn in at least 3 source code files, one header file and 2 source code files.) Remember that your header file contains just definitions and not source code. You must also turn in all 3 (or more) of your test input files (.txt).
Do not use a vector, you can use a simple array. Do not use anything that would require you to include the libraries algorithm.h or vector.h or similar. If you have any questions about this, let me know before submitting the assignment. Remember that your code must be appropriately commented. You must use inline comments and block comments. (Your class member function comment blocks should be above your function declarations in your header file.)