Question: 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

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. Trying to complete this using multiple threads or multiple processes.

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

  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
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!