Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 0 additions & 8 deletions .claude/settings.local.json

This file was deleted.

6 changes: 2 additions & 4 deletions algorithm_theory/binary_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
the interval is empty.
"""

from typing import Optional


def binary_search_iterative(array: [int], target: int) -> Optional[int]:
def binary_search_iterative(array: list[int], target: int) -> int | None:
"""Narrow the [left, right] bounds by half each iteration until target is found or the bounds cross."""
left = 0
right = len(array) - 1
Expand All @@ -26,7 +24,7 @@ def binary_search_iterative(array: [int], target: int) -> Optional[int]:
return None


def binary_search_recursive(array: [int], left: int, right: int, target: int) -> Optional[int]:
def binary_search_recursive(array: list[int], left: int, right: int, target: int) -> int | None:
"""Recurse into the left or right sub-array each call until target is found or the bounds cross."""
if right >= left:
mid = int((left + right) / 2)
Expand Down
2 changes: 1 addition & 1 deletion algorithm_theory/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def bubble_sort(array: [int]) -> []:
def bubble_sort(array: list[int]) -> list[int]:
"""Bubble Sort.

The simplest sorting algorithm, working by repeatedly swapping the adjacent elements if they are
Expand Down
3 changes: 1 addition & 2 deletions algorithm_theory/jump_search.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import math
from typing import Optional

from algorithm_theory.linear_search import linear_search


def jump_search(array: [int], target: int) -> Optional[int]:
def jump_search(array: list[int], target: int) -> int | None:
"""Jump Search (https://www.geeksforgeeks.org/jump-search/).

A searching algorithm for sorted arrays. The basic idea is to check fewer elements (than linear
Expand Down
5 changes: 1 addition & 4 deletions algorithm_theory/linear_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from typing import Optional


def linear_search(array: [int], left: int, right: int, target: int) -> Optional[int]:
def linear_search(array: list[int], left: int, right: int, target: int) -> int | None:
"""Linear Search.

The most basic search. Start from the leftmost element of the array and one by one compare the target
Expand Down
Loading
Loading