Skip to content
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
92204dc
fix: update binary search for first occurrence and fix syntax errors
tusharynayaka Mar 3, 2026
ca1c615
fix: binary search first occurrence and resolve global ruff linting e…
tusharynayaka Mar 3, 2026
9fe6d31
fix: binary search first occurrence and resolve global ruff linting e…
tusharynayaka Mar 3, 2026
a1b12ac
fix: binary search first occurrence and resolve global ruff linting e…
tusharynayaka Mar 3, 2026
4dc8470
fix: binary search first occurrence and resolve global ruff linting e…
tusharynayaka Mar 3, 2026
c23157f
fix: binary search first occurrence and resolve global ruff linting e…
tusharynayaka Mar 3, 2026
e94ff2c
fix: total cleanup of jump_search for ruff and mypy
tusharynayaka Mar 3, 2026
3c96273
fix: address ruff I001, UP047, and W292 in jump_search
tusharynayaka Mar 3, 2026
d308b35
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2026
2662eb5
Merge branch 'master' into fix-binary-search-final
tusharynayaka Mar 18, 2026
a48a595
Merge branch 'master' into fix-binary-search-final
tusharynayaka Mar 31, 2026
d43ff7c
Merge branch 'master' into fix-binary-search-final
tusharynayaka Apr 8, 2026
b13b6e0
fix: remove hidden whitespace and fix newline in jump_search
tusharynayaka Mar 3, 2026
4235f83
Fix: implement first occurrence logic and restore doctests
tusharynayaka Apr 9, 2026
5ede257
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2026
f858e21
style: fix import sorting to satisfy ruff
tusharynayaka Apr 9, 2026
40090f0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2026
f059c6d
final: restore original doctests and fix logic inconsistencies
tusharynayaka Apr 9, 2026
5a9e860
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2026
893abd3
Merge branch 'master' into fix-binary-search-final
tusharynayaka Apr 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: binary search first occurrence and resolve global ruff linting e…
…rrors
  • Loading branch information
tusharynayaka committed Mar 3, 2026
commit c23157fc897c0c0964906b89a9ba9cc245cc0f22
2 changes: 1 addition & 1 deletion searches/jump_search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any

Check failure on line 1 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

searches/jump_search.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports
"""
Pure Python implementation of the jump search algorithm.
This algorithm iterates through a sorted collection with a step of n^(1/2),
Expand All @@ -9,9 +9,9 @@
https://en.wikipedia.org/wiki/Jump_search
"""

import math

Check failure on line 12 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

searches/jump_search.py:12:1: E402 Module level import not at top of file
from collections.abc import Sequence

Check failure on line 13 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F401)

searches/jump_search.py:13:29: F401 `collections.abc.Sequence` imported but unused help: Remove unused import: `collections.abc.Sequence`

Check failure on line 13 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

searches/jump_search.py:13:1: E402 Module level import not at top of file
from typing import Any, Protocol, TypeVar

Check failure on line 14 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F811)

searches/jump_search.py:14:20: F811 Redefinition of unused `Any` from line 1: `Any` redefined here searches/jump_search.py:1:20: previous definition of `Any` here help: Remove definition: `Any`

Check failure on line 14 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

searches/jump_search.py:14:1: E402 Module level import not at top of file


class Comparable(Protocol):
Expand All @@ -21,7 +21,7 @@
T = TypeVar("T", bound=Comparable)


def jump_search(arr: list[Any], x: Any) -> int:
def jump_search(arr: list, x) -> int:

Check failure on line 24 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (ARG001)

searches/jump_search.py:24:28: ARG001 Unused function argument: `x`
"""
Python implementation of the jump search algorithm.
Return the index if the `item` is found, otherwise return -1.
Expand All @@ -44,17 +44,17 @@

prev = 0
step = block_size
while arr[min(step, arr_size) - 1] < item:

Check failure on line 47 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F821)

searches/jump_search.py:47:42: F821 Undefined name `item`
prev = step
step += block_size
if prev >= arr_size:
return -1

while arr[prev] < item:

Check failure on line 53 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F821)

searches/jump_search.py:53:23: F821 Undefined name `item`
prev += 1
if prev == min(step, arr_size):
return -1
if arr[prev] == item:

Check failure on line 57 in searches/jump_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F821)

searches/jump_search.py:57:21: F821 Undefined name `item`
return prev
return -1

Expand Down
Loading