Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given below is a sequential program that calculates the frequency of even values in a large array. Your task is to develop a parallel solution

Given below is a sequential program that calculates the frequency of even values in a large array. Your task is to develop a parallel solution that distributes the workload over the number of processors on the machine executing your program (construct the Threaded class and the main method to test it).
public static void main(String[] args){ int f[]= new int[1000000];
for(int j =0; j < f.length;j++) f[j]=(int)(Math.random()*100000); int freq =0;
for(int j =0; j < f.length; j++)
if(f[j]%2==0) freq++; System.out.println(freq);
}
The number of processors is given by Runtime.getRuntime().availableProcessors())

Step by Step Solution

3.55 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Here is the parallel solution that distributes the workload over the number of processors available in the machine executing the program as per the in... 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

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago