HarshCasper / NeoAlgo

Bringing all Data Structures and Algorithms under one Roof ⚡
MIT License
875 stars 1.05k forks source link

Bug at Binary Search #7587

Closed mohanadtalat91 closed 2 years ago

mohanadtalat91 commented 2 years ago

https://github.com/HarshCasper/NeoAlgo/blob/4f1e5bdd6d9d899fa354de94740e0aecf5ecd2be/Go/search/binary_search/binary_search.go#L24

Here is a bug at the above line, which will case an overflow if low = 10^9 and high = 1, because 10^9 + 1 will cause overflow. So it must be low + (high-low)/2 instead of (high+low) / 2.

github-actions[bot] commented 2 years ago

Hello @mohanadtalat91,
Thank you for opening an issue. :partying_face:
To get assigned to this particular issue please use /assign
Check this guide before contributing.

mohanadtalat91 commented 2 years ago

/assign

github-actions[bot] commented 2 years ago

Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Telegram or ping one of the reviewers. Thank you for your contributions!