Saturday, June 20, 2020

Mock interview: binary search algorithm

Here is the gist.




Actionable Item 

Follow up
June 20, 2020 10:00 PM

 Actually I found out that my code has a bug.

The statement is wrong, it can be a deadloop:

while(numbers[start] <= numbers[end])

It should be while(start <= end).

When I fixed my bug of mixing start with numbers[start], I just quickly updated while statement.

I should stay calm, and think about it before I make the change. This is a terrible mistake.

10:20 PM

while(numbers[start] <= numbers[end])

Also there is index-out-of-range error as well besides deadloop.



No comments:

Post a Comment