chap file processing and external sorting randomaccessfile(string namestring mode)class constructoropens disk file for processing read(byte[ )read some bytes from the current position in the file the current position moves forward as the bytes are read write(byte[ )write some bytes at the current position in the file (overwriting the bytes already at that positionthe current position moves forward as the bytes are written seek(long pos)move the current position in the file to pos this allows bytes at arbitrary places within the file to be read or written close()close file at the end of processing external sorting we now consider the problem of sorting collections of records too large to fit in main memory because the records must reside in peripheral or external memorysuch sorting methods are called external sorts this is in contrast to the internal sorts discussed in which assume that the records to be sorted are stored in main memory sorting large collections of records is central to many applicationssuch as processing payrolls and other large business databases as consequencemany external sorting algorithms have been devised years agosorting algorithm designers sought to optimize the use of specific hardware configurationssuch as multiple tape or disk drives most computing today is done on personal computers and low-end workstations with relatively powerful cpusbut only one or at most two disk drives the techniques presented here are geared toward optimized processing on single disk drive this approach allows us to cover the most important issues in external sorting while skipping many less important machine-dependent details readers who have need to implement efficient external sorting algorithms that take advantage of more sophisticated hardware configurations should consult the references in section when collection of records is too large to fit in main memorythe only practical way to sort it is to read some records from diskdo some rearrangingthen write them back to disk this process is repeated until the file is sortedwith each record read perhaps many times given the high cost of disk /oit should come as no surprise that the primary goal of an external sorting algorithm is to minimize the amount of information that must be read from or written to disk certain amount of additional cpu processing can profitably be traded for reduced disk access before discussing external sorting techniquesconsider again the basic model for accessing information from disk the file to be sorted is viewed by the programmer as sequential series of fixed-size blocks assume (for simplicitythat each