Bifalgorithm post

Whenever I go to a party, I always show people how quickly I can implement binary search. Usually nobody cares, but once somebody actually pointed out a bug in my implementation, if left and right are really big numbers, these might actually overflow a 32 bit integer. The way to make the same calculation without doing that is by taking the difference between right and left, dividing that by two and then adding the result to the left pointer. You can see it still works. But this time we don't have the bug. If you want to learn more, check out this free roadmap I created only on neatcode.io.

Whenever I go to a party, I always show people how quickly I can implement binary search. Usually nobody cares, but once somebody actually pointed out a bug in…

Ideas in this flowchart

  • Party Demonstration
  • Binary Search Implementation
  • Show Quick Implementation
  • Typical Reaction
  • Nobody Cares
  • Bug Detection
  • Bug in Implementation
  • Overflow Risk
  • Solution to Overflow
  • Calculate Mid Safely
  • Verification
  • No Bug Present
  • Learning Resource
  • Free Roadmap on neatcode.io
Feed/

Whenever I go to a party, I always show people how quickly I can implement binary search. Usually nobody cares, but once somebody actually pointed out a bug in my implementation, if left and right are really big numbers, these might actually overflow a 32 bit integer. The way to make the same calculation without doing that is by taking the difference between right and left, dividing that by two and then adding the result to the left pointer. You can see it still works. But this time we don't have the bug. If you want to learn more, check out this free roadmap I created only on neatcode.io.

"Whenever I go to a party, I always show people how quickly"

👍
0
0 comments0 shares

Sign in to view and post comments.