从具有数十亿个数字的文件中查找1000个最大数字 [英] Finding 1000 largest numbers from a file having some billion numbers

查看:87
本文介绍了从具有数十亿个数字的文件中查找1000个最大数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




从文件中找到1000个最大数字的最佳方法

有多少条目?你能帮我找一下

的方式吗?我需要去B +树吗?


请帮助,

Subramanya M

Hi,

What is the best way to find the 1000 largest numbers from the file
having hell lot of entries ? Can you please help me to find out the
way ? Do I need to go for B+ trees ??

Please help,
Subramanya M

推荐答案

在文章< 11 ********************* @ 30g2000cwc.googlegroups.c om>,

Subra< ma ********* @ gmail.comwrote:
In article <11*********************@30g2000cwc.googlegroups.c om>,
Subra <ma*********@gmail.comwrote:

找到1000个最大数字的最佳方法是什么文件
有多少条目?你能帮我找一下
方式吗?我需要去B +树吗?
What is the best way to find the 1000 largest numbers from the file
having hell lot of entries ? Can you please help me to find out the
way ? Do I need to go for B+ trees ??



这实际上只是一个算法问题,与

中的C无关。


我看不到一个更好的方法来做到这一点,而不是保持1000个最大的到目前为止

在一个排序列表中有一些结构允许你快速插入

a新项目在正确的位置并丢弃旧的第1000个数字。

A B + -tree有这些属性。


记下当前的第1000个值你甚至可以在不看树的情况下丢弃
较小的值。如果你真的有一个数十亿美元的数字,并且它们是随机的,那么绝大多数将会比现在的第1000个小,所以效率是结构

你保持最大的1000可能不太重要。你可以考虑平均插入次数如何随文件中

项目的数量而变化。


- 理查德


-

在一些字母表中需要考虑多达32个字符

" - X3.4,1963。

This is really just an algorithm question, nothing to do with C in
particular.

I can''t see a better way to do it than keeping the 1000 largest so far
in a sorted list with some structure that allows you to quickly insert
a new item in the correct position and discard the old 1000th number.
A B+-tree has those properties.

Keep a note of the current 1000th value so that you can discard
smaller values without even looking at the tree. If you really have a
billion numbers, and they''re in a random order, the vast majority will
be smaller than the currernt 1000th, so the efficiency of the structure
in which you keep the largest 1000 may be of little importance. You
might consider how the average number of insertions varies with the
number of items in the file.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.


Subra写道:
Subra wrote:



从文件中找到1000个最大数字的最佳方法

有多少条目?你能帮我找一下

的方式吗?我需要去B +树吗?
Hi,

What is the best way to find the 1000 largest numbers from the file
having hell lot of entries ? Can you please help me to find out the
way ? Do I need to go for B+ trees ??



我建议使用堆,就像在Heapsort中一样。


-

Eric Sosman
es*****@acm-dot-org.inva lid

I''d suggest using a heap, as in Heapsort.

--
Eric Sosman
es*****@acm-dot-org.invalid


3月6日,10:30,Subra < mailursu ... @ gmail.comwrote:
On 6 Mar, 10:30, "Subra" <mailursu...@gmail.comwrote:

从文件中找到1000个最大数字的最佳方法

地狱很多?你能帮我找一下

的方式吗?我需要去B +树吗?
What is the best way to find the 1000 largest numbers from the file
having hell lot of entries ? Can you please help me to find out the
way ? Do I need to go for B+ trees ??



排序文件|尾巴-1000

sort file | tail -1000


这篇关于从具有数十亿个数字的文件中查找1000个最大数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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