Open AhmedSeemalK opened 6 months ago
[!TIP] I can email you next time I complete a pull request if you set up your email
The sandbox appears to be unavailable or down.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
binary_search.py
✓ https://github.com/psurabh/build_tools/commit/b300381a7ef3f8b767964386c1b7c025abc2568b Edit
Create binary_search.py with contents:
• Create a new Python file named binary_search.py.
• At the top of the file, add a docstring that describes the purpose of the file (i.e., to implement a binary search algorithm).
• Define a function named binary_search that takes two parameters: a sorted list named lst and a search key named key.
• Inside the function, add error checking to ensure that lst is not empty. If it is, return -1.
• Also inside the function, add error checking to ensure that lst is sorted. If it is not, return -1.
• Still inside the function, implement the binary search algorithm using a while loop. The loop should continue as long as the search interval is not empty. Inside the loop, calculate the middle index of the current search interval. If the value at this index is equal to key, return the index. If the value is less than key, update the search interval to be the upper half. If the value is greater than key, update the search interval to be the lower half.
• After the loop, return -1 to indicate that key is not in lst.
• At the bottom of the file, add a main block that tests the binary_search function with various inputs and prints the results.
binary_search.py
✓ Edit
Check binary_search.py with contents:
Ran GitHub Actions for b300381a7ef3f8b767964386c1b7c025abc2568b:
I have finished reviewing the code for completeness. I did not find errors for sweep/write_a_python_program_to_for_binary_sea
.
💡 To recreate the pull request edit the issue title or description.Something wrong? [Let us know].
This is an automated message generated by Mi6
Checklist
- [X] Create `binary_search.py` ✓ https://github.com/psurabh/build_tools/commit/b300381a7ef3f8b767964386c1b7c025abc2568b [Edit](https://github.com/psurabh/build_tools/edit/sweep/write_a_python_program_to_for_binary_sea/binary_search.py) - [X] Running GitHub Actions for `binary_search.py` ✓ [Edit](https://github.com/psurabh/build_tools/edit/sweep/write_a_python_program_to_for_binary_sea/binary_search.py)