Question: Write an efficient java program to implement external soring, given a big data file of integers, where the number of inputs is unknown but the

Write an efficient java program to implement external soring, given a big data file of integers, where the number of inputs is unknown but the first data of the input file is the largest array size (M) that can be used.

Print content of each generated sorted file as well as the final sorted file using formatted (%6d ) and 10 integers per line.

Your main method should be as follow:

public static void main(String args[]) throws exception{

extsort = new ();

try{

k = extsort extsort.gensortedfiles(); // k sorted files will be generated

for ( i = 1; i k; i++)

extsort.printfile(F + i+ .txt); // Print content of file i

// end for

extsort.mergefiles(k); // merge k sorted files F1, F2,Fk, using 2way merge

extsort.printfile(F.txt); // Print final sorted file

}catch (Exception e) {prt(" Exception " + e + " ");}

}// end main method

If the input file is as follows:

5 63 60 16 47 8 12 50 21 67 7 35 27 20 24 18 32 32 18 24 15

Then the soring phase (using replacement selection) of your java program (xxxxxp2.java) should generate 3 sorted files as follows:

F1: 8 12 16 21 47 50 60 63 67

F2: 7 18 20 24 27 32 32 35

F3:15 18 24

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!