Revise Listing 30.10, ParallelMergeSort.java, to define a generic parallelMergeSort method as follows: Listing public static void parallelMergeSort(E[]
Question:
Revise Listing 30.10, ParallelMergeSort.java, to define a generic parallelMergeSort method as follows:
Listing
Transcribed Image Text:
public static
public static > void parallelMergeSort(E[] list) 1 import java.util.concurrent.RecursiveAction; 2 import java.util.concurrent. ForkJoinPool; 3 4 public class ParallelMergeSort { public static void main(String[] args) { final int SIZE = 7000000; int[] listl = new int[SIZE]; int[] list2 = new int[SIZE]; 5 for (int i = 0; i < list1.length; i++) list1[i] = list2[i] = (int)(Math.random() * 10000000); 10 11 12 13 14 15 16 17 18 19 20 21 22 long startTime = System.currentTimeMillis(); parallelMergeSort(list1); // Invoke parallel merge sort 1ong endTime = System.currentTimeMillis(); System.out.printin("\nParallel time with + Runtime.getRuntime().availableProcessors() + processors is " + (endTime - startTime) + "milliseconds"); startTime = System.currentTimeMillis(); MergeSort.mergeSort(1ist2); // MergeSort is in Listing 23.5 endTime = System.currentTimeMillis(); System.out.println("\nSequential time is " + (endTime - startTime) + " milliseconds"); 23 24 25 26 public static void parallelMergeSort(int[] list) { RecursiveAction mainTask = new SortTask(list); ForkJoinPool pool = new ForkJoinPool(); pool.invoke (mainTask); 27 28 29 30 31 32 { 33 private static class SortTask extends RecursiveAction { private final int THRESHOLD 34 500;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (6 reviews)
Program Plan Design a generic solution to the parallel merge sort problem using data type making the type generic Useas the datatype to make the program accept any primitive datatype as method argumen...View the full answer
Answered By
Jinah Patricia Padilla
Had an experience as an external auditor in Ernst & Young Philippines and currently a Corporate Accountant in a consultancy company providing manpower to a 5-star hotel in Makati, Philippines, Makati Diamond Residences
5.00+
120+ Reviews
150+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Revise BST in Listing 25.5, using a generic parameter and a Comparator for comparing objects. Define a new constructor with a Comparator as its argument as follows:BST(Comparator comparator) Listing...
-
Revise MyPriorityQueue in Listing 24.9, using a generic parameter for comparing objects. Define a new constructor with a Comparator as its argument as follows:PriorityQueue(Comparator comparator)...
-
Revise Heap in Listing 23.9, using a generic parameter and a Comparator for comparing objects. Define a new constructor with a Comparator as its argument as follows:Heap(Comparator comparator)...
-
The unadjusted trial balance of Simple Consulting Services as at December 31, 2021 is as follows: Cash Accounts receivable Prepaid insurance Supplies inventory Office equipment Accumulated...
-
Explain why natural selection has favored the instability of RNA.
-
Develop a one-week schedule for your Housekeeping employees. Using the Excel spreadsheet that is attached above, you will prepare a schedule for the week The day-by-day occupied rooms forecast has...
-
\(500 \mathrm{~kg} / \mathrm{h}\) of a \(30 \mathrm{wt} \%\) pyridine, \(70 \mathrm{wt} \%\) water feed is extracted with \(300 \mathrm{~kg} / \mathrm{h}\) of pure chlorobenzene at \(1...
-
Would Lyles claim of racial discrimination be for intentional (disparate-treatment) or unintentional (disparate-impact) discrimination? Explain. Amaani Lyle, an African American woman, was hired by...
-
Consider a person who begins contributing to a retirement plan at age 2 5 and contributes for 4 0 years until retirement at age 6 5 . For the first 1 0 years, she contributes $ 2 7 2 per month. She...
-
In HTTP, draw a figure to show the application of cookies in a web portal using two sites.
-
Implement the following method using the Fork/Join Framework to assign random values to the list. public static void parallelAssignValues(double[] list) Write a test program that creates a list with...
-
Implement the following method in parallel to sort a list using quick sort (see Listing 23.7).public static void?parallelQuickSort(int[] list)Write a test program that times the execution time for a...
-
The first assignment in a statistical computing class involves running a short program. If past experience indicates that 40% of all students will make no programming errors, compute the...
-
Evaluate the role of dystopian fiction in reflecting societal fears and concerns. What are the common tropes of this genre, and how do different authors use them to critique contemporary issues ?
-
How does hypertextual fiction transform traditional storytelling? Consider the interactive nature of hypertext and discuss its implications for narrative structure, reader agency, and storytelling...
-
An LC series circuit is comprised of a 1 . 0 - mF capacitor in series with an inductor. The period of electromagnetic oscillations in this circuit is 1 0 0 ms. What is the inductance of the inductor?
-
This is Bobby. He is 8 years old. Despite the fact that he is reminded frequently to clean up, his room is always in a state of disarray. His father would like to increase the frequency of Bobby...
-
Virtual meetings using collaboration software is generally used when participants are dispersed over a large geographic area. Research on the Internet for software being used today and register for a...
-
Develop a resource loading table using MS Project. Use the resource leveling feature in MS Project to level your project. Assume that each of your people is devoting 40 hours per week on this...
-
On January 1, 2017, McIlroy, Inc., acquired a 60 percent interest in the common stock of Stinson, Inc., for $340,200. Stinson's book value on that date consisted of common stock of $100,000 and...
-
Recall the simple model for HTTP streaming shown in Figure 9.3. Recall that B denotes the size of the client's application buffer, and Q denotes the number of bits that must be buffered before the...
-
Consider the figure below. Similar to our discussion of Figure 9.1. Suppose that video is encoded at a fixed bit rate, and thus each video block contains video frames that are to be played out over...
-
Reconstruct Table 9.1 for when Victor Video is watching a 4 Mbps video, Facebook Frank is looking at a new 100 Kbyte image every 20 seconds, and Martha Music is listening to 200 kbps audio stream....
-
Dog Up! Franks is looking at a new sausage system with an installed cost of $685,000. This cost will be depreciated straight-line to zero over the project's 5-year life, at the end of which the...
-
Pascale has just finished college and started her career. She plans to start saving money early so that she can retire at age 5 5 . She decides that she needs $ 8 0 0 0 0 0 . 0 0 when she retires. a...
-
Based on the preceding results, is the sample median an unbiased estimator of the population median? Why or why not? A. The sample median targets the population median. As such, the sample median...
Study smarter with the SolutionInn App