Question: In C++ For this assignment, you will create a parallel Fibonacci code generator using multiple processes and threads. In mathematics and computing, Fibonacci coding is

In C++

For this assignment, you will create a parallel Fibonacci code generator using multiple processes and threads.

In mathematics and computing, Fibonacci coding is a universal code that encodes positive integers into binary code words. It is one example of representations of integers based on Fibonacci numbers. Each codeword ends with "11" and contains no other instances of "11" before the end.

You need to implement a parallel Fibonacci code generator based on the following steps:

  1. Read the alphabet of the original message (string) and the name of the input file (string) from STDIN.
  2. Calculate the frequency of the symbols in the alphabet in the input file. For each symbol in the alphabet, you must create a child process or a thread to calculate the assigned symbol's frequency.
  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 symbol's ASCII value to break the tie (the higher the value, the higher the priority).
  4. Assign a positive integer value (starting from 1) to the symbols in the sorted alphabet. For each symbol in the alphabet, you must create a process or a thread to generate its Fibinnaci code based on the assigned integer value.
  5. Print the codes of the symbols in the alphabet sorted in increasing order by their ASCII value.

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 the output statement format based on the example below.
  • 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.

EXAMPLE:

STDIN input:
aeiou input1.txt 
input1.txt content:
aaaeeeiiiooouuuuuuuuuuuuuuuuaaeeeeeeeiiiiiiiiiiiiiiiiiiiiiiiiiiiiaaaaa
Expected output: 
 

Symbol: a, Frequency: 10, Code: 1011 Symbol: e, Frequency: 10, Code: 0011 Symbol: i, Frequency: 31, Code: 11 Symbol: o, Frequency: 3, Code: 00011 Symbol: u, Frequency: 16, Code: 011

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!