S
spidrw
I'm writing this program to implement a two phase multi-way merge sort.
It works by splitting the data to be sorted into temporary sorted
lists (output files) equal in size to a memory constraint that is
passed in when the program is run. What I've got to do now is actually
merge the lists into one final output. The trick is that this is
supposed to save disk I/Os. What happens is I read the smallest
element from each temporary file into an array. From that array, the
smallest goes into the final output, and that element is then replaced
by the next element from the same list.
I feel like what I need to do is delete a number from one of the
temporary when it's read into the array. Then all I have to do is read
the first line from the same list to get the next number into the
merging array. Any suggestions on how to do this?
I'm using SDK 1.4.2 and the input/output files are binary, so I'm using
DataInput/OutputStream to do this.
Thanks,
Andrew Weber
It works by splitting the data to be sorted into temporary sorted
lists (output files) equal in size to a memory constraint that is
passed in when the program is run. What I've got to do now is actually
merge the lists into one final output. The trick is that this is
supposed to save disk I/Os. What happens is I read the smallest
element from each temporary file into an array. From that array, the
smallest goes into the final output, and that element is then replaced
by the next element from the same list.
I feel like what I need to do is delete a number from one of the
temporary when it's read into the array. Then all I have to do is read
the first line from the same list to get the next number into the
merging array. Any suggestions on how to do this?
I'm using SDK 1.4.2 and the input/output files are binary, so I'm using
DataInput/OutputStream to do this.
Thanks,
Andrew Weber