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 upJump search #2415
Merged
Jump search #2415
+30
−4
Conversation
| import math | ||
|
|
||
|
|
||
| def jump_search(arr, x): | ||
| def jump_search(arr: list, x: int) -> int: |
This comment has been minimized.
This comment has been minimized.
ruppysuppy
Sep 11, 2020
Contributor
Suggested change
| def jump_search(arr: list, x: int) -> int: | |
| def jump_search(arr: List[int], x: int) -> int: |
First import List from typing
This comment has been minimized.
This comment has been minimized.
cclauss
Sep 11, 2020
•
Member
This limits us to only the int data type. Without this specificity, would the algorithm work with strings, tuples, floats?
searches/jump_search.py
Outdated
| x = 55 | ||
| user_input = input("Enter numbers separated by a comma:\n").strip() | ||
| arr = [int(item) for item in user_input.split(",")] | ||
| x = int(input("Enter the number to be searched:\n")) | ||
| print(f"Number {x} is at index {jump_search(arr, x)}") |
This comment has been minimized.
This comment has been minimized.
ruppysuppy
Sep 11, 2020
Contributor
-1 is a valid position in python, check if the number is found before printing it
TravisBuddy
commented
Sep 11, 2020
|
Hey @BriseBalloches, TravisCI finished with status TravisBuddy Request Identifier: 1fc95270-f450-11ea-a882-ef0b60d9fbb3 |
|
Modified. Thanks. |
| >>> jump_search([-5, -2, -1], -1) | ||
| 2 | ||
| >>> jump_search([0, 5, 10, 20], 8) | ||
| -1 |
This comment has been minimized.
This comment has been minimized.
cclauss
Sep 11, 2020
Member
I tend to like to raise an exception like str.index() vs str.find() but that is a personal choice.
|
LGTM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.


BriseBalloches commentedSep 10, 2020
Describe your change:
Added type hinting, docstring, doctest for jump search algorithm.
Checklist:
Fixes: #{$ISSUE_NO}.