You will implement an external sorting algorithm for binary data. The input data file will consist of many 4-byte records, with each record consisting of two 2-byte (short) integer values in the range 1 to 30,000. The first 2-byte field is the key value (used for sorting) and the second 2-byte field contains a data value. The input file is guaranteed to be a multiple of 4096 bytes. All I/O operations will be done on blocks of size 4096 bytes (i.e., 1024 logical records).
Your job is to sort the file (in ascending order), using a modified version of Quicksort. The modification comes in the interaction between the Quicksort algorithm and the _le storing the data. The array being sorted will be the _le itself, rather than an array stored in memory. All accesses to the file will be mediated by a buffer pool. The buffer pool will store 4096-byte blocks (1024 records). The buffer pool will be organized using the Least Recently Used (LRU) replacement scheme.
Design Considerations: The primary design concern for this project will be the interaction between the array as viewed by the Quicksort algorithm, and the physical representation of the array as implemented by the disk file mediated by the buffer pool. You should pay careful attention to the interface that you design for the buffer pool, since you will be using this again in Project 4. In essence, the disk file will be the array, and all accesses to the array from the Quicksort algorithm will be in the form of requests to the buffer pool for specific blocks of the file.
The data file is the file to be sorted. The sorting takes place in that file, so this program does modify the input data file. Be careful to keep a copy of the original when you do your testing. The parameter determines the number of buffers allocated for the buffer pool. This value will be in the range 1-20. The parameter is the name of a file that your program will generate to store runtime statistics; see below for more information.
At the end of your program, the data file (on disk) should be in a sorted state. Do not forget to use buffers from your buffer pool as necessary at the end, or they will not update the file correctly.

Respuesta :

This is Java program for quicksort to implement an external sorting algorithm for binary data.

Step-by-step coding:

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.File;

import java.io.IOException;

public class Quicksort

{

   public static void main(String[] args)

       throws IOException

   {

       String disk = args[0];

       int numBuffer = Integer.parseInt(args[1]);

       String statFile = args[2];

       // stat info update

       Stat.fileName = disk;

       long start = System.currentTimeMillis();

       // sort file

       Sorting sorting = new Sorting(disk, numBuffer);

       sorting.sort();

       // flush when sorting is done.

       sorting.flush();

       long end = System.currentTimeMillis();

       // update stat info.

       Stat.executionTime = end - start;

       // write stat info to file:

       File stat = new File(statFile);

       stat.createNewFile();

       FileWriter statfileWriter = new FileWriter(stat, true);

       BufferedWriter statOut = new BufferedWriter(statfileWriter);

       statOut.write(Stat.output());

       statOut.flush();

       statOut.close();

   }

}

To learn more about Quicksort in Java, visit: https://brainly.com/question/13155236

#SPJ4