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

Question #245599

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


1
Expert's answer
2021-10-03T04:01:21-0400
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

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