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.
-
Two coupled coils have self-inductances L 1 = 50 mH and L 2 = 200 mH, and a coefficient of coupling k = 0.50. If coil 2 has 1000 turns, and i 1 = 5.0 sin 400t (A), find the voltage at coil 2 and the...
-
This case arose after Felix DeWeldon, a well-known sculptor and art collector, sold three paintings to Robert McKean in 1994. Felix DeWeldon declared bankruptcy in 1991. In 1992, DeWeldon, Ltd.,...
-
Kraft Unlimited, Inc., was organized and authorized to issue 5,000 shares of $100 par value, 9 percent preferred stock and 50,000 shares of no par, $5 stated value common stock on July 1, 2014....
-
What is one of the Oracle database upgrade methods. Which of the methods offers the least control over the upgrade process? Please explain thoroughly because I am having a hard time with this subject...
-
The following information relates to Home Depot, Inc., and Lowes Companies, Inc. for their 2017 and 2016 fiscal years. Required a. Compute the following ratios for the companies 2017 fiscal years...
-
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...
-
For a particular model of car, bought for 14 750, the second-hand value after t years is given fairly accurately by the formula The running costs of the car increase as the car gets older, so after t...
-
How should the balance of accounts payable be reported in the financial statements?
-
Explain whether you agree with the possible expected challenges in the specialized field of accounting. Why or why not?
-
a. Compute the cash received by the borrower. $ 96,000 * b. Prepare a debt amortization schedule. Note: Round each amount in the table to the nearest whole dollar. Note: Use a negative sign for the...
-
Jane, an HR manager at ABC Inc., is responsible for managing the company's employee engagement program. One day she receives a complaint from an employee about the company's new dress code policy,...
-
Good Coffee is a coffee product retailer and manufacturer located in Irvine, CA. The company president is Josh Ryan, who inherited the company. When the company was founded over 50 years ago, it...
-
Indicate in each of the following independent situations whether the taxpayer can accomplish what is proposed. Provide adequate authority for your answer including any special elections that are...
-
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....
-
4. Elizabeth has $1537.21 in her savings account. The account pays 4% compounded monthly. Elizabeth does not make any deposits or withdrawals over the next 6 months. How much interest does the...
-
7. Part of an amortization table is shown below. Determine the missing values in the table labeled A, B, C, D Payment Monthly Interest Principal Outstanding A) number payment paid paid balance 0 $175...
-
3. Calculate the following dosages according to kilogram of body weight: a. The physician ordered Zovirax capsules 5 mg/kg every 8 hours for 7 days for a patient who has a diagnosis of herpes zoster....
Study smarter with the SolutionInn App