Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The prompt that i posted below tells you what you will need to be adding to this JAVA code. THIS HAS TO BE IN JAVA!!
The prompt that i posted below tells you what you will need to be adding to this JAVA code. THIS HAS TO BE IN JAVA!!
you will have to implement external sort to this Java. once tou go through the copiable java code you will see that in some if the methods it says "Complete the Method". that is what you will compete.
i hope this is enoufh information and once agaim this HAS TO HE IN JAVA
-----JAVA-----
import java.util.*;
import java.io.*;
//CSUN Comp 282 Sp 21 Homework-2
//Implementing external sort:
//For sort phase using normal sort and
//for merge phase using 2way merge.
//Author:
public class xxxxxh2 {
//class used for search
int heap[], M;//M is largest array size
//use a short word for System.out to save typing
PrintStream prt = System.out;
// print file formatted k integers per line
private void prtfile(String fn, int k){
//declare variables
int i = 0, x;
prt.printf(" \t%s:",fn);
try {
Scanner inf = new Scanner(new File(fn));
while (inf.hasNext()) {
//read an input from fname
x = inf.nextInt();
prt.printf("%3d ", x);
i++;
if(i % k == 0) prt.printf(" \t");
}//end while
//close file
inf.close();
}catch (Exception e){
prt.printf(" Ooops! Read Exception: %s", e);
}//end prtfile
//print n files
private void prtfiles(int n, int k) {
int i;
String fname;
for (i = 1; i
fname = "F" +i+".txt";
prtfile(fname, k);
}
}//end prtfiles
/ormalsort, creating arrays of size n
private int normalsort(){
//COMPLETE THIS METHOD
}//end normal sort
//2way merge n sorrted files
private int merge2way(int n){
//COMPLETE THIS METHOD
}// end merge2way
/way merge n sorted files
private int mergenway(int n){
//COMPLETE THIS METHOD
}//end mergenway
//merge 2 sorted files f1, f2 into f3
private int merge(String f1, String f2, String f3){
//COMPLETE THIS METHOD
}//end merge
//Heapsort heap[] with n integers
private void heapsort(int n){
//COMPLETE THIS METHOD
}//end sort
public static void main(String[] args) throws Exception{
int n, k = 15; // print 15 integers per line
xxxxxh2 srt = new xxxxxh2();
n = srt.normalsort(); // n is no. of sorted files created
srt.prtfiles(n, k);
System.out.printf(" Overall %4d sorted files are created", n);
srt.merge2way(n); // Merging n sorted files using 2-way merge
srt.mergenway(n); Merging n sorted files using n-way merge
//OPTIONAL Print execution time of both merges
System.out.printf(" \tAuthor: Gh. Dastghaibyfard Date: " +
java.time.LocalDate.now());
}//end main
}//end xxxxxH2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started