Write a program which takes as input a huge array of numbers. This array is
split into n sub-arrays and n threads apply a bubble sort on each of the n
sub-arrays. Lastly, another thread merges the n sorted sub-arrays into one
with the same size as the original array. Of course, the resulting array
should be sorted
import java.util.*;
public class Main{
static void splitArray(int arr[], int N, int K)
{
Vector<Integer> v = new Vector<Integer>();
Vector<Character> v2 = new Vector<Character>();
for(int i = 1; i < N; ++i)
{
v.add(arr[i - 1] - arr[i]);
}
Collections.sort(v);
for(int i=0; i<v.size(); i++){
System.out.println(v.get(i));
}
}
public static void main(String[] args)
{
System.out.println("Enter number of elements in the list: ");
Scanner input=new Scanner(System.in);
int num = input.nextInt();
int [] array1=new int[num];
System.out.println("Enter elements of the array: ");
for(int i=0;i<num;i++){
array1[i]=input.nextInt();
}
int k = 3;
splitArray(array1, num, k);
}
}v
Comments
Leave a comment