Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question1 (parallel vs. sequential): In this question, we need to measure the time difference between performing certain tasks sequentially and dividing and then performing the

Question1 (parallel vs. sequential):

In this question, we need to measure the time difference between performing certain tasks sequentially and dividing and then performing the same task in parallel. Create a class named STUDENT, that holds the students GPA (float value between 2.0 to 4.0), AGE (integer value between 18 to 30), and ID (unique integer value per student). For each of the following versions, calculate (using Java.Time or the Java API you find appropriate) how long each version takes in seconds.

Sequential version (Name this file as Q1_SeqV.java): o Create a list of 50,000 students with randomly generated GPAs, randomly generated Ages, and sequential IDs. o After creating the list, your program calculates and prints the average GPA and average AGE.

Parallel version 1 (Name this file as Q1_PLV1.java):

o Repeat the sequential version using two threads along with the main thread. o Each thread creates a list of 25,000 students with randomly generated GPAs, randomly generated Ages, and sequential IDs. o Each of the two threads then calculates the average GPA and AGE (after creating the lists). o The two threads work in parallel. o The main thread waits for the two threads to finish and then calculates and prints the final average GPA and AGE from what

is reported by the individual threads. Parallel version 2 (Name this file as Q1_PLV2.java):

o Repeat the Parallel version1 task using five threads (each is working on 10000 students) along with the main thread. To measure the time your computer takes to complete a certain task:

Read and store the current time (t1) before you start the task (e.g., before creating the lists), After the task (e.g., after calculating the average), read and store the current time (t2). The time it takes your computer to complete the task is then: t2 t1.

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

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

Students also viewed these Databases questions

Question

c. How is trust demonstrated?

Answered: 1 week ago

Question

Have issues been prioritized?

Answered: 1 week ago

Question

d. How will lack of trust be handled?

Answered: 1 week ago