3 ms·
Yup, no sigar. 1. You get a division by zero when $start == $end 2. When the element $search doesn't exist your program breaks 3. You always check array for
by gizmo 17y ago
Yup, no sigar.
1. You get a division by zero when $start == $end
2. When the element $search doesn't exist your program breaks
3. You always check array for value $middle, so $middle should have the range 0 <= $middle < length($array). But according to the comment $start cannot be zero. If so, then $middle is always larger than zero, and as such, the first element of the array is never considered.
So it's pretty buggy.
- ohashi 17y ago1. i knew there was issue with start==end. what is the solution for that issue? i had originally written $start<=$end 2. i think this is connected to previous issue, with ending it 3. I knew the zero thing would be an issue, but... had to write it before caps game started :(