Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUpdate linear_search.py #2422
Update linear_search.py #2422
Conversation
Python implementation of recursive linear search algorithm
@Ashley-J-George Hi there, Your first PR ever huh? Good luck! It looks like you did not provide any doctests for There is an issue when, for example, Also, type hints for both def rec_linear_search(sequence: list, low: int, high: int, target: float) -> int: |
Added different doctests Added the parameter hints Handled the exception
TravisBuddy
commented
Sep 14, 2020
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: 340dc310-f65d-11ea-afed-a1bc0e34d213 |
Hey @Ashley-J-George, TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself. @cclauss @spamegg1 How should I rectify this? My actual code is ` def rec_linear_search(sequence: list, low: int, high: int, target: int) -> int:
def main():
if name == 'main': ` |
When the element is not found I have made the function return -1, and added
a try except to handle the index error
…On Mon, Sep 14, 2020 at 1:08 PM Christian Clauss ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In searches/linear_search.py
<#2422 (comment)>:
> +
+ Examples:
+ >>> linear_search([0, 5, 7, 10, 15], 0)
+ 0
+
+ >>> linear_search([0, 5, 7, 10, 15], 15)
+ 4
+
+ >>> linear_search([0, 5, 7, 10, 15], 5)
+ 1
+
+ >>> linear_search([0, 5, 7, 10, 15], 6)
+
+ '''
+ if high < low:
+ return None
We promised on line 41 that this function would return an it but now we
are returning an non-int. We have two choices:
1. Return -1 as a signal that the element is not in the list --or--
2. Raise an error.
This is like str.find()
<https://docs.python.org/3/library/stdtypes.html#str.find> vs. str.index
<https://docs.python.org/3/library/stdtypes.html#str.index>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2422 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJUYHLIMUQZOAKBQSFPDUITSFXB6PANCNFSM4RK2FGDQ>
.
|
added parameter hints to linear_search
TravisBuddy
commented
Sep 14, 2020
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: 156ed5e0-f660-11ea-afed-a1bc0e34d213 |
@Ashley-J-George Build log says
Very easy to fix! Check out CONTRIBUTING.md about running |
Nice work!! |
Thank You! |
This comment has been minimized.
This comment has been minimized.
tamkiti
commented on 8520694
Sep 14, 2020
good thank you |
This comment has been minimized.
This comment has been minimized.
tamkiti
replied
Sep 14, 2020
|
This comment has been minimized.
This comment has been minimized.
marsine
replied
Sep 14, 2020
And you to thank's
…On Mon, 14 Sep 2020, 3:02 pm tamkiti, ***@***.***> wrote:
good thank you
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<8520694#commitcomment-42292849>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP35DG6M4IZM3A6AR5CO4Z3SFYPABANCNFSM4RLUIMOQ>
.
|
This comment has been minimized.
This comment has been minimized.
tamkiti
replied
Sep 14, 2020
Thank you |
Ashley-J-George commentedSep 13, 2020
•
edited
I've added a Python implementation of recursive search algorithm
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.