Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a simple C code to compute histograms of characters that leverage the power of multiprogramming. Your program should read a text file and print

Write a simple C code to compute histograms of characters that leverage the power of multiprogramming. Your program should read a text file and print a histogram of letters present in each line. Use your knowledge of threads and processes to parallelize it to run faster.

There are two parts to this assignment. First, you must decide whether multi-threading or multi-processing is more appropriate for this use case. Write a short report (1-page) choosing between the two and justifying your choice.

Second, you must write a C program to read a file, compute the histogram and print it per line. Your code must take in as an argument the number of threads/processes. Each thread/process must process one line and print its histogram and exit. Make sure that your code is not data-dependent i.e., each line must be processed by exactly one thread/process.

The data to test your code will be provided. An example of a histogram for a line is given below:

Input: The quick brown fox jumps over the lazy dog

Output: {'a': 1, 'b': 1, 'c': 1, 'd': 1, 'e': 3, 'f': 1, 'g': 1, 'h': 2, 'i': 1, 'j': 1, 'k': 1, 'l': 1, 'm': 1, 'n': 1, 'o': 4, 'p': 1, 'q': 1, 'r': 2, 's': 1, 't': 2, 'u': 2, 'v': 1, 'w': 1, 'x': 1, 'y': 1, 'z': 1}

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_2

Step: 3

blur-text-image_3

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago