Answered step by step
Verified Expert Solution
Link Copied!

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
image text in transcribed
NOTE: Homeworks will not be graded if: Your complete homework is not in a SINGLE xxxxxH2.java file, where xxxxx is at most the 1st first 5 characters of your last name and H2 is the Homework number. Using package or have compile error. Does not compile or execute at the command prompt. It does not read input, from any input file. It's sent by email. Save the following java program into xxxxxH2.java and do as follow: a) Do not modify main method, except writing your name in line 83 and OPTIONAL part). b) Implement external sort: for sort phase use normal sort, for merge phase use two way merge to merge n sorted files (merge2way(n)), for array sort use heapsort. Also write merge(f1, f2, f3) to merge two sorted files f1 and f2 into f3.. c) OPTIONAL EXTRA POINT: Write mergenway(n) method and print execution time of both merges for initial input file over 10MB data. (100 Pts) d) A sample input is as follow:Note:Fist input is max array size for sort 10 84 82 52 80 96 85 75 75 82 87 92 89 57 94 93 92 63 99 87 72 73 56 74 50 84 62 72 55 86 75 74 100 83 60 53 68 89 67 66 65 72 94 73 54 98 96 85 75 75 82 87 92 89 To compile: javac xxxxxh2.java To execute: java xxxxxh2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions