Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The java program contains an incomplete findMin method, which is designed to find the smallest element in an array. You are to complete the method

The java program contains an incomplete findMin method, which is designed to find the smallest element in an array. You are to complete the method by creating Thread objects that operate on different sections of the array and combine the results. Be sure to consider the case of arrays in which the number of elements is not a multiple of the number of Threads created.

/** Exercise to use multi-threaded programming in finding the smallest element in an array. */ public class ParallelHW1 { public static final int NUM_THREADS = 4; public static final int SIZE1 = 12; public static final int SIZE2 = 15; public static void main(String[] args) { int [] array1 = {10, 20, 30, 40, 50, 0, 70, 80, 90, 100, 110, 120}; int [] array2 = {10, 20, 30, 40, 50, 60, 70, 80, 90, -10, 110, 120, 0, -20, -5}; System.out.println(findMin(array1, SIZE1)); System.out.println(findMin(array2, SIZE2)); } /** Creates multiple threads to find the smallest value in an array @param array1 array of values to be processed @param length number of array elements */ public static int findMin(int[] array1, int length) { // Code goes Here //Donot change anything else. } }

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Communicating Organizational Culture

Answered: 1 week ago