iiitv / algos

Popular Algorithms and Data Structures implemented in popular languages
MIT License
1.07k stars 496 forks source link

Fix #822 added Binary Search[CPP] #830

Closed varunvilva closed 1 year ago

varunvilva commented 1 year ago

Fixes #822

By submitting this pull request I confirm I've read and complied with the below declarations.

Output: image

varunvilva commented 1 year ago

I am taking the index number as the input for the function binary search. So it will not produce overflow.If in input high is taken as array length then it will cause overflow. I have also seen some codes use mid = low + (high - low) /2 are you referring to this as overflow?

kalashshah commented 1 year ago

Yes mid = (low + high) / 2 can cause overflow