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.by using Multi-Threading
package splitarrays;
import java.util.*;
public class SplitArrays{
static void split_array(int arr[], int N, int K)
{
Vector<Integer> vect = new Vector<Integer>();
for(int i = 1; i < N; ++i)
{
vect.add(arr[i - 1] - arr[i]);
}
Collections.sort(vect); //Sorting the sub arrays
for(int i=0; i<vect.size(); i++){
System.out.println(vect.get(i));
}
}
public static void main(String[] args)
{
int a[] = { 9,10,22,55,89,223 };
int n = a.length;
int k = 3;
split_array(a, n, k);
}
}
Comments
Leave a comment