Talk:Binary search: Difference between revisions

no edit summary
(omg)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 22:
why not high=mid-1
and low=mid+1
?
? --~~~~
</pre>
--[[User:Walterpachl|Walterpachl]] 12:00, 3 December 2013
 
== Recursive binary search in C ==
Is there any reason why <code>n</code> is passed as argument in <code>int bsearch_r (int *a, int n, int x, int i, int j)</code> ? --[[User:Natema|Natema]] ([[User talk:Natema|talk]]) 05:31, 10 February 2016 (UTC)
: I agree with your hint - that parameter does look to be unnecessary. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 11:42, 10 February 2016 (UTC)
 
== MATLAB ==
 
It seems the initial value for 'high' in the iterative example is too low:
<pre>high = numel(list) - 1; </pre>
For a list with one entry, the solution shown will access element 0 of 'list', out of bounds.
1

edit