Last active
March 7, 2022 02:20
-
-
Save MithraTalluri/b7cccb146aac5038871e5e908f43de38 to your computer and use it in GitHub Desktop.
Conditions for Binary Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
low | high | mid | while(?) | |
---|---|---|---|---|
mid + 1 | mid - 1 | low + ((high - low) / 2) | low <= high | |
mid + 1 | mid | low + ((high - low) / 2) | low < high | |
mid | mid - 1 | low + ((high - low + 1) / 2) | low < high | |
mid | mid | X (infinite loop) | X (invalid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment