Created
January 6, 2026 12:24
-
-
Save pythonhacker/f9868683e257a695dfe32624c515e1a0 to your computer and use it in GitHub Desktop.
Demo of binary search using bisect
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
| >>> l = [10, 15, 18, 20, 21, 21, 21, 24, 24] | |
| >>> binary_search(l, 18) | |
| 2 | |
| >>> binary_search(l, 21) | |
| 4 | |
| >>> binary_search(l, 24) | |
| 7 | |
| >>> binary_search(l, 100) | |
| -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment