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/9383facb92e9b1dd8713560d920120eb74480aef Edit
Create binary_search.py with contents:
• Create a new Python file named binary_search.py.
• In this file, define a function named binary_search that takes two parameters: a sorted list named lst and a target value named target.
• The function should implement the binary search algorithm. It should start by initializing two variables, low and high, to the first and last indices of the list, respectively. Then, it should enter a while loop that continues as long as low is less than or equal to high.
• Inside the loop, the function should calculate the middle index of the current search interval, check the value at this index, and update low or high accordingly. If the value at the middle index is equal to the target, the function should return the middle index. If the value at the middle index is less than the target, the function should set low to the middle index plus one. If the value at the middle index is greater than the target, the function should set high to the middle index minus one.
• If the loop finishes without finding the target, the function should return None.
• After the function definition, add a main block that tests the binary_search function with different lists and target values and prints the results.
binary_search.py
✓ Edit
Check binary_search.py with contents:
Ran GitHub Actions for 9383facb92e9b1dd8713560d920120eb74480aef:
I have finished reviewing the code for completeness. I did not find errors for sweep/write_a_binary_search_in_python
.
💡 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/9383facb92e9b1dd8713560d920120eb74480aef [Edit](https://github.com/psurabh/build_tools/edit/sweep/write_a_binary_search_in_python/binary_search.py) - [X] Running GitHub Actions for `binary_search.py` ✓ [Edit](https://github.com/psurabh/build_tools/edit/sweep/write_a_binary_search_in_python/binary_search.py)