一个问题:200,000元素数组是否值得排序和搜索? [英] A question: Is 200,000 element array worth sorting and search?

查看:91
本文介绍了一个问题:200,000元素数组是否值得排序和搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主题来自一个问题:


您是否愿意等待快速排序,线性搜索,

或冒泡排序等结果一个200000元素阵列?

1Quicksort

2线性搜索

3Bubble排序


答案是2Linear搜索


有人可以解释为什么选择Linear Search,而不是其他两个选项吗?

或者我误解了原来的问题?


谢谢你们!

The topic comes from a question:

Would you rather wait for the results of a quicksort, a linear search,
or a bubble sort on a 200000 element array?
1Quicksort
2Linear Search
3Bubble Sort

The answer is 2Linear Search

Could someone explain why Linear Search, not the other two options?
Or I misunderstood the original question?

Thanks you guys!

推荐答案

5月4日23:27,mike-yue< needpass ... @ gmail.comwrote:
On 4 May, 23:27, mike-yue <needpass...@gmail.comwrote:

主题来自一个问题:


您是否愿意等待快速排序,线性搜索的结果,

或200000元素阵列上的冒泡排序?

1Quicksort

2线性搜索

3Bubble排序

答案是2线性搜索


有人可以解释为什么线性搜索,而不是oth呃两个选择?
The topic comes from a question:

Would you rather wait for the results of a quicksort, a linear search,
or a bubble sort on a 200000 element array?
1Quicksort
2Linear Search
3Bubble Sort

The answer is 2Linear Search

Could someone explain why Linear Search, not the other two options?



嗯,这是一个很糟糕的问题:询问你/你想做什么;但是

假设你想等待尽可能少的时间没有选择

2最快完成?事实上排序和搜索完成了不同的事情似乎也会让人感到困惑。


您可能更好地提出有关编程的问题(即不在C上)

comp.programming。


-

Well, it''s a poor question: asking what /you/ would prefer to do; but
presuming you want to wait as little time as possible wouldn''t option
2 finish soonest? The fact that sorting and searching accomplish
different things also seems to be there to confuse.

You might be better asking questions on programming (i.e. not on C) in
comp.programming.

--


mike-yue说:
mike-yue said:

主题来自一个问题:


您是否愿意等待快速排序,线性搜索的结果,

或200000元素阵列上的冒泡排序?

1Quicksort

2线性搜索

3Bubble排序


答案是2线性搜索


有人可以解释为什么有线性搜索,而不是其他两个选项吗?

或者我误解了原文题?
The topic comes from a question:

Would you rather wait for the results of a quicksort, a linear search,
or a bubble sort on a 200000 element array?
1Quicksort
2Linear Search
3Bubble Sort

The answer is 2Linear Search

Could someone explain why Linear Search, not the other two options?
Or I misunderstood the original question?



问题是测试你对算法复杂性的了解。


随着数据项数量的增加(特别是超过限制)在哪里你可以合理地认为所有数字基本上都是相同的大小),你可以开始忽略诸如开销成本之类的微小因素(例如,打开一个
文件)甚至,在某种程度上,机器速度!重要的是,对于

大N,N是如何影响算法的。


Quicksort是O(N * log N)。线性搜索是O(N)。冒泡排序为O(N * N)。


要理解,请绘制图表。


-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日

The question is testing your knowledge of algorithmic complexity.

As the number of data items rises (especially past the limit where you can
reasonably think of all numbers as being basically the same size), you can
begin to ignore minor factors like the cost of overheads (e.g. opening a
file) and even, to some extent, the machine speed! All that matters, for
large N, is how this N affects the algorithm.

Quicksort is O(N * log N). Linear search is O(N). Bubble sort is O(N * N).

To understand, plot the graphs.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


mike-yue写道:
mike-yue wrote:

主题来自一个问题:


您是否宁愿等待快速排序,线性

搜索或200000元素阵列上的冒泡排序结果?

1Quicksort

2线性搜索

3Bubble排序


答案是2线性搜索


有人可以解释为什么是线性搜索,而不是其他两个选项吗?

或者我误解了原来的问题?
The topic comes from a question:

Would you rather wait for the results of a quicksort, a linear
search, or a bubble sort on a 200000 element array?
1Quicksort
2Linear Search
3Bubble Sort

The answer is 2Linear Search

Could someone explain why Linear Search, not the other two options?
Or I misunderstood the original question?



鉴于1和3是排序,2是搜索,并且鉴于它'

远不清楚什么' '结果''你应该等待,我会说

你误解了,或者你误会了它。


无论如何,这是一个通用的编程问题,而不是C语言的问题




-

彼得

Given that 1 and 3 are sorts, and 2 is a search, and given that it''s
far from clear what ''result'' you''re supposedly waiting for, I''d say
you have misunderstood, or you''ve mis-remembered it.

In any case, this is a general programming question, not a question
on the C language.

--
Peter


这篇关于一个问题:200,000元素数组是否值得排序和搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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