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:
- Read the alphabet of the original message (string) and the name of the input file (string) from STDIN.
- 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.
- 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).
- 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.
- 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
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