This pull request adds a Python program that implements a binary search algorithm. The program takes a sorted list and a key as input and returns the index of the key in the list. If the list is not sorted or the key is not in the list, it returns -1.
Summary
Added a new file binary_search.py which contains the implementation of the binary search algorithm.
The function binary_search(lst, key) performs the binary search. It takes a list and a key as input and returns the index of the key in the list.
The function returns -1 if the list is not sorted or the key is not in the list.
Included test cases in the __main__ section to verify the functionality of the binary search algorithm.
Fixes #22.
🎉 Latest improvements to Mi6:
#
💡 To get Mi6 to edit this pull request, you can:
Comment below, and MI6 can edit the entire PR
Comment on a file, Mi6 will only modify the commented file
Edit the original issue to get Mi6 to recreate the PR from scratch
Description
This pull request adds a Python program that implements a binary search algorithm. The program takes a sorted list and a key as input and returns the index of the key in the list. If the list is not sorted or the key is not in the list, it returns -1.
Summary
binary_search.py
which contains the implementation of the binary search algorithm.binary_search(lst, key)
performs the binary search. It takes a list and a key as input and returns the index of the key in the list.__main__
section to verify the functionality of the binary search algorithm.Fixes #22.
🎉 Latest improvements to Mi6:
#💡 To get Mi6 to edit this pull request, you can: