Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the following example Mergesort and MergeSortTest, to sort the array of integers using the mergesort algorithm concurrently. Create threads to run each recursive call

Modify the following example Mergesort and MergeSortTest, to sort the array of integers using the mergesort algorithm concurrently. Create threads to run each recursive call using a separate thread. First code: package mergesort;
import java.util.Random;
public class MergeSort {
private int[] data;
private static final Random generator = new Random();
public MergeSort(int size){
data = new int[size];
for (int i=0; i=1)
{
int middle1=(low + high)/2;
int middle2= middle1+1;
System.out.println("split: "+ subarray(low,high));
System.out.println(""+ subarray(low,middle1));
System.out.println(""+ subarray(middle2,high));
System.out.println();
sortArray(low, middle1);
sortArray(middle2, high);
merge(low, middle1, middle2, high);
}
}
public String subarray(int low, int high){
StringBuilder temporary = new StringBuilder();
for (int i=0; i

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

Students also viewed these Databases questions