Tuesday, January 16, 2018

Code review: Binary search

January 16, 2018

Introduction


It is my time to learn some new ideas to write binary search. I learned the new way to find smallest index today. But I like to look into the idea and see if there is any pitfall on that.

Code review

I like to study the code and give some code review. The code is here.

A few things I gave in the discussion:

1. Ask the question about arr[i] - i, how to prove that it is not descending. It cannot take for granted.
2. Advice to write down some analysis before writing the code; write down the constraint, what to find. The peer missed the keyword: lowest index.
3. Binary search while loop, should include = sign.
4. Coding style

No comments:

Post a Comment