用很小的物理内存将10亿个整数排序到SORT [英] to SORT 1 BILLION of integer numbers with small physical memory

查看:211
本文介绍了用很小的物理内存将10亿个整数排序到SORT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想对10亿个整数进行排序,而我的系统只有1 GB的RAM.什么是最快,最有效的排序方式?

Want to SORT 1 BILLION of integer numbers and my system has just 1 GB of RAM.What could be the fastest and efficient way to sort?

  1. 假设我们在文本文件中每行输入一个整数.

  1. Say we have an input in a text file an integer per line.

我们正在使用Java程序进行排序.

We are using java program to sort.

我指定了RAM,因为我们无法在RAM中保存所有输入整数.

I have specified RAM as we cannot hold all the input integers in the RAM.

更新:整数是7位数字.

推荐答案

最简单的方法是将输入分成较小的文件,这些文件可以放入内存中并对其进行排序,然后合并结果.

The simplest thing to do is break the input into smaller files that can fit in memory and sort each, and then merge the results.

Guido van Rossum表现出色在python中进行此操作的说明,但显然语言不相同,原理是相同的.

Guido van Rossum has a good description of doing this in python while obviously not the same language the principle is the same.

这篇关于用很小的物理内存将10亿个整数排序到SORT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆