Answer to Question #242865 in Java | JSP | JSF for kavin

Question #242865

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


1
Expert's answer
2021-09-27T04:52:43-0400


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);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS