-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mi6: write a python program to for binary search (✓ Sandbox Passed) #23
base: main
Are you sure you want to change the base?
Conversation
Rollback Files For Mi6
This is an automated message generated by Mi6 |
Apply to your PR?
This is an automated message generated by Mi6 |
Apply to your PR?
This is an automated message generated by Mi6 |
Add docstrings to all functions and file headers. |
binary_search.py
Outdated
This file implements a binary search algorithm. | ||
""" | ||
|
||
def binary_search(lst, key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mi6: Add docstring to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Wrote Changes
Done.
This is an automated message generated by Mi6
high = mid - 1 | ||
return -1 | ||
|
||
if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add a docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring to the function
binary_search.py
Outdated
This file implements a binary search algorithm. | ||
""" | ||
|
||
def binary_search(lst, key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mi6: add a docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mi6: Add docstring to the function
binary_search.py
Outdated
This file implements a binary search algorithm. | ||
""" | ||
|
||
def binary_search(lst, key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring to the function
binary_search.py
Outdated
This file implements a binary search algorithm. | ||
""" | ||
|
||
def binary_search(lst, key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mi6: Add docstring to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mi6: Add docstrings to all functions and file headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mi6: Add docstrings to all functions and file headers.
binary_search.py
Outdated
if lst != sorted(lst): | ||
return -1 | ||
|
||
low, high = 0, len(lst) - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the variable to meaningful names
binary_search.py
Outdated
This file implements a binary search algorithm. | ||
""" | ||
|
||
def binary_search(lst, key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mi6: Give meaningful variable names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Wrote Changes
Done.
This is an automated message generated by Mi6
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: