How to speed up external merge sort in Java

后端 未结 4 1451
忘掉有多难
忘掉有多难 2021-01-21 05:02

I am writing code for the external merge sort. The idea is that the input files contain too many numbers to be stored in an array so you read some of it and put it into files to

4条回答
  •  感动是毒
    2021-01-21 05:43

    We have implemented a public domain external sort in Java:

    http://code.google.com/p/externalsortinginjava/

    It might be faster than yours. We use strings and not integers, but you could easily modify our code by substituting integers for strings (the code was made hackable by design). At the very least, you can compare with our design.

    Looking at your code, it seems like you are reading the data in units of integers. So IO will be a bottleneck I would guess. With external memory algorithms, you want to read and write blocks of data---especially in Java.

提交回复
热议问题