logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

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

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

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. 

EXAMPLE:

Input file contents:

aaaeeiaaeeiiioouuuuuuuua

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

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

545 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

733 Answers

Hire Me
expert
Husnain SaeedComputer science

596 Answers

Hire Me
expert
Atharva PatilComputer science

915 Answers

Hire Me