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.
-
Effect of transaction on statement of cash flows. (Requires coverage of Appendix 8.1.) Refer to the simplified statement of cash flows in Exhibit 4.12. Numbers appear on 1 1 of the lines in the...
-
The chapter lists employer and employee objectives in relation to payment. What changes would you make to these lists? LO7
-
Ace Racket Company manufactures two types of tennis rackets, the Junior and Pro Striker models. The Production budget for May for the two rackets is as follows: Both rackets are produced in two...
-
! Required information [The following information applies to the questions displayed below.) Mason (single) is a 50 percent shareholder in Angels Corp. (an S Corporation). Mason receives a $187,500...
-
Deanas Services Company had account balances as follows: Accounts payable ......... $ 9,900 Accounts receivable ........ 26,950 Cash ............... 11,390 Fees earned ............. 70,800 Insurance...
-
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...
-
What are the extremely fine holes that interconnect plant cells? What is the name of the especially thin areas of walls where these holes are particularly common (Figure 3-37)? Figure 3-37 Cell 1...
-
Define HIPPA? What is the purpose of HIPPA? What are the 4 main rules of HIPPA?
-
Accounting for Inventories" Please respond to the following: As a Financial Accountant,determine the best type of income statement a retailer should use.Defend your suggestion. Analyze inventory...
-
A baseball player's slugging percentage SLG can be calculated with the following formula (which is an example of a rational function): SLG = H+2B+2x(3B)+3x(HR) AB Q Image transcription text H+2B+2x...
-
Question During 2021, Cassandra Albright, who is single, worked part-time at a doctor's office and received a W-2. She also had a cash-basis consulting practice that had the following income and...
-
Shelly Beaman (social security number 412-34-5670) Is single and resides at 540 Front Street, Ashland, NC 27898. Shelly's W-2 wages Federal withholding Social security wages Social security...
-
To start her old lawn mower, Rita has to pull a cord and hope for some luck. On any particular pull, the mower has a 20% chance of starting. a. Find the probability that it takes her exactly 3 pulls...
-
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....
-
How do liquid assets differ from illiquid assets? Discuss with examples
-
Bobcat Enterprises is considering a new three-year expansion project that requires an initial fixed asset investment of $1.80 million. The fixed asset will be depreciated straight-line to zero over...
-
A portfolio manager oversees a $1 billion U.S. equity portfolio and wants to use the standard S&P 500 futures to hedge the entire portfolio. Assume the portfolio has a beta of 1.10 to the S&P 500...
Study smarter with the SolutionInn App