Question: Computer Science - Java Help Below, I have attached code for mergeSort and my output. The objective is to sort the text files input_100.txt ,

Computer Science - Java Help

Below, I have attached code for mergeSort and my output. The objective is to sort the text files "input_100.txt" , "input_1000.txt" and record the time it takes for it to sort the random numbers on each txt file. My output only displays the sorted numbers for input_1000.txt but not input_100.txt. Please fix code or make new code that displays the sorted numbers for each txt file as well as shows how much time it takes. I cannot attach the actual two txt files, so make your own . Please format your code and take a pic of the output. Thanks.

Code:

import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class mergeSort { public static void main(String args[]) throws FileNotFoundException { int arr[],temp[],index=0; String Filename[] = new String[]{"input_100.txt" , "input_1000.txt"}; //Save filenames in a variable double times[] = new double [Filename.length]; int file1=0,file2=0; Scanner number; for (int n = 0; n high then the array will be sorted else sort the array int mid=low+(high-low)/2;//calculate mid index to break the array into two halves merge_sorting(arr,temp,low,mid);//calling sorting function to sort the left subarray merge_sorting(arr,temp,mid+1,high);//calling sorting function to sort the right subarray merge(arr,temp,low,mid,high);//calling function to merge two subarrays } } public static void merge(int ar[],int temp[],int low,int m, int high){//merging function for(int i=0;i

Screenshot of output:

Computer Science - Java Help Below, I have attached code for mergeSort

Compile MessagesjGRASP Messages Run l/O Interactions File End Clear Help Recorded time 202.0 nanosecond to sort file input_100.txt File Recorded time 218.0 nanosecond to sort file input_1000.txt 0 0 0 001 1 1 2 2 2 2 2 333 45 7778 8 8 99 9 10 11 11 12 12 13 13 14 14 15 15 15 16 16 16 18 18 jGRASP: operation complete

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!