Talk:Algorithm Implementation/Search/Binary search
From Wikibooks, the open-content textbooks collection
[edit] Python
The Pyhon code does not actually work: center is only set once to len(seq) / 2 and then never changes => the function will always return − 2 − len(seq) / 2 - unless search < seq[0].
This clearly shows that algorithm-code-snippets must always be accomplished by a test suite to be useful to the reader.
Of course only the Ada Programming authors make the effort. And to allow myself a little ranting: It show the difference between a community of software-engineers and community of code-hackers.
--Krischik T 13:22, 29 June 2006 (UTC)
PoisoneR - I add working python code and also java implementation.
[edit] C++
I added two separate C++ implementations, one that is recursive and probably better for learning, and one that is generic. The generic one should be good for people learning to write generic algorithms via C++ templates. Any comments, criticisms improvements welcome --Etscrivner 05:21, 26 March 2007 (UTC)