Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

here is my code for #1. #include #include using namespace std; void myCompress(fstream &output, char lastRead, int sameNumOfChara) { if (lastRead == '0') { output

image text in transcribed

here is my code for #1.

#include #include using namespace std;

void myCompress(fstream &output, char lastRead, int sameNumOfChara) { if (lastRead == '0') {

output

int main() { fstream input; fstream output; input.open("input.txt"); output.open("output.txt");

char chara; char current; char lastRead = ' '; int sameNumOfChara = 0;

while (input.get(chara)) {

current = chara;

if (current != lastRead) {

if (sameNumOfChara >= 16) { myCompress(output, lastRead, sameNumOfChara); } else { for (int i = 0; i

if (sameNumOfChara >= 16) {

myCompress(output, lastRead, sameNumOfChara); }

else {

for (int i = 0; i

}

Need to create a concurrent version of it

This is the question of #1

image text in transcribed

Thanks in advance, need help :(

(concurrency) Write a concurrent version of the compression described above in problem #1. Create very large file, divide the file into equal chunks (say n) and allocate the work to n processes forked. Then assemble the result of each process and output it. You will have an input data file and output compressed data file. (ParFork.cParFork) (System calls) Write a C program that makes compressed copy of an existing file of bits (O's and 1's) using system calls for file manipulation. For compression use the following rules: a. Compress only the sequence of length >= 16 l's or 0's; for example a sequence of 26 0's is replaced by -26- and a sequence of 78 l's is replaced by +78+ b. Sequence of l's and 0's of length . Example input file: 110000101010101010101010101010101010101010101010101010101 0101011010101010000000000000000000000000000000000001 0111111111111111111111111 This has 3 segments as shown by the different colors. The compressed output file for this will be: 111111111110000101010101010101010101010101010101010101010101010101 010101 101010101-36-1 0+24+ The names of the two files, source and the destination are to be specified as command line arguments. Open the source file in read only mode and destination file in read/write mode. While the main function will carry out file opening and closing, a separate compress function needs to be written to do the actual compressing and copying. {MyCompress.c MyCompress} Your program should work with the large test file you can come up with. For simplicity in 10 processing assume the input file of l's and 0's is a file of characters. The output file will have characters of l's and 0's as well as the compressed information as numerical value. While you may use the data given above for prototyping, you will need fairly large data files to get some realistic time measurements. (concurrency) Write a concurrent version of the compression described above in problem #1. Create very large file, divide the file into equal chunks (say n) and allocate the work to n processes forked. Then assemble the result of each process and output it. You will have an input data file and output compressed data file. (ParFork.cParFork) (System calls) Write a C program that makes compressed copy of an existing file of bits (O's and 1's) using system calls for file manipulation. For compression use the following rules: a. Compress only the sequence of length >= 16 l's or 0's; for example a sequence of 26 0's is replaced by -26- and a sequence of 78 l's is replaced by +78+ b. Sequence of l's and 0's of length . Example input file: 110000101010101010101010101010101010101010101010101010101 0101011010101010000000000000000000000000000000000001 0111111111111111111111111 This has 3 segments as shown by the different colors. The compressed output file for this will be: 111111111110000101010101010101010101010101010101010101010101010101 010101 101010101-36-1 0+24+ The names of the two files, source and the destination are to be specified as command line arguments. Open the source file in read only mode and destination file in read/write mode. While the main function will carry out file opening and closing, a separate compress function needs to be written to do the actual compressing and copying. {MyCompress.c MyCompress} Your program should work with the large test file you can come up with. For simplicity in 10 processing assume the input file of l's and 0's is a file of characters. The output file will have characters of l's and 0's as well as the compressed information as numerical value. While you may use the data given above for prototyping, you will need fairly large data files to get some realistic time measurements

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What is meant by terms of trade? How is it determined?

Answered: 1 week ago

Question

Explain the causes of indiscipline.

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago