Why Binary Search is Taught Wrong | Let's Fix Your Code
Easy Theory
Here we show why binary search is often taught with a subtle bug that would be really hard to detect without really thinking about how binary search actually works. We show a pseudocode implementation and go over why some languages would cause such a bug to occur, and a possible fix. Specifically, the bug is an overflow when computing the midpoint. This algorithm is taken from leetcode.com, which shows that you shouldn't just blindly implement an algorithm taken from something you read online.
Easy Theory Website: https://www.easytheory.org Discord: https://discord.gg/SD4U3hs
If you like this content, please consider subscribing to my channel: https://www.youtube.com/channel/UC3VY6RTXegnoSD_q446oBdg?sub_confirmation=1
▶ABOUT ME◀ I am a professor of Computer Science, and am passionate about it. I have taught many courses at several different universities, including several sections of undergraduate and graduate theory-level classes.
The views expressed in this video are not reflective of any of my current or former employers. ... https://www.youtube.com/watch?v=MhEQdHLyrcg
126933494 Bytes