二进制搜索问题?问题

由网友(话不投机聊你妈逼)分享简介:可能重复: What在执行二进制搜索的陷阱? 我仔细阅读了二进制搜索的维基百科页面和克努特下面无意中发现了一个报价:I was perusing the wikipedia page for Binary Search and stumbled on a quote by Knuth below: 虽然二进制搜...

可能重复:   What在执行二进制搜索的陷阱?

我仔细阅读了二进制搜索的维基百科页面和克努特下面无意中发现了一个报价:

I was perusing the wikipedia page for Binary Search and stumbled on a quote by Knuth below:

虽然二进制搜索的基本思想是比较直观,细节更是出奇地刁钻

"Although the basic idea of binary search is comparatively straightforward, the details can be surprisingly tricky"

我记得实施多项二进制搜索我的计算机科学课程的一部分,但不记得它是非常棘手的。但是,这篇文章指出,90%的受访专业人士不能几个小时后得到一个工作。我想承担这一不因为这些是可怕的程序员,但有附带案件天真实现不占。

I recall implementing several Binary Searches as part of my Computer Science curriculum, but don't remember it being terribly tricky. However, this article states that 90% of surveyed professionals can't get one working after several hours. I'd like to assume this not because these are terrible programmers, but that there are fringe cases that naive implementations don't account for.

什么是细节,克努特是指呢?什么是常见的问题要注意,如果实现的二进制搜索算法?

What are the details that Knuth is referring too? What are the common gotchas to be aware of if implementing a Binary Search algorithm?

请注意,我读了一篇文章布洛赫有关的编程珠玑的错误(int型的中点溢出)。还有什么?

Note I read that article by Bloch about the Programming Pearls bug(overflow of an int for midpoint). Is there anything else?

推荐答案

作为一个在Java世界在我的日常工作​​,我记得的这个。我是pretty的惊讶,当我第一次读到它,这可能是的东西唐纳德在谈论的。

Being in Java world in my day job, I remember this. I was pretty surprised when I first read it so this may be one of the things Donald was talking about.

阅读全文

相关推荐

最新文章