you will create a parallel fixed-length code generator using the tools we learned in class to create multiple processes and threads.C++ Programming

Programming Assignment

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


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.


    • 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. 


Input file contents:


Expected output:

Symbol: a, Frequency: 6, Code: 001

Symbol: e, Frequency: 4, Code: 011

Symbol: i, Frequency: 4, Code: 010

Symbol: o, Frequency: 2, Code: 100

Symbol: u, Frequency: 8, Code: 000



Instructions Files

C++ Programming Experts

Eric Bell
C++ Programming

88 Answers

Dinh Hong P.
C++ Programming

20 Answers

View More Experts

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.

Get Free Quote!

265 Experts Online