You must select the appropriate tool the implement the parallel code generator. Not using multiple threads or multiple processes will translate into a penalty of 100%.

computer science

Description

Programming Assignment


Requested files: main.cpp, FixedLengthCoder.h, FixedLengthCoder.cpp

Problem:

For this assignment, you will create a parallel fixed-length code generator using the tools we learned in class to create multiple processes and threads.

Computers represent a character as a sequence of 8 bits, which means that you can represent up to 256 symbols per character. However, depending on the source, it is common to have messages/files using an alphabet with a size of fewer than 256 symbols.

The simplest way to achieve compression is to use a fixed-length code generator. The idea behind this type of code generators is to assign a fixed-length bit sequence to each symbol of the alphabet.

You need to implement a fixed-length code generator based on the following steps:

  1. Read the contents of a text file (the filename will be given as a command line argument).
  2. Generate the alphabet used in the input file and determine the frequency and the first position for each symbol in the alphabet.
  3. Sort the alphabet in decreasing order based on the frequency of the symbols. If two or more symbols have the same frequency, you will use the ASCII value of the symbol to break the tie.
  4. Assign the code to the symbols in the alphabet. For each symbol in the alphabet, you must create a process or a thread to generate its code. You must guarantee that each symbol has the same number of bits. To calculate the number of bits used per symbol you will use the following formula: ceil(log2(size of the alphabet)).
  5. Print the codes of the symbols in the alphabet sorted in increasing order by their first appearance in the input file.

NOTES:

    • You must select the appropriate tool the implement the parallel code generator. Not using multiple threads or multiple processes will translate into a penalty of 100%.
    • You must use forks and parent/child threads, or you will get 0%.
    • You must use the output statement format based on the example below. To guarantee consistency when printing the characters of the alphabet to STDOUT, replace the '\n' character with the string "<EOL>".
    • You can implement your solution only using the requested file main.cpp (you do not need to use the provided files to implement an OOP based solution).
    • You can safely assume that the input will always be valid. 


Related Questions in computer science category