Skip to content

bug(searches): jump_search raises IndexError for empty list input #15085

Description

@Kanika0306

Repository commit

f5988cc

Python version (python --version)

Python 3.14.6

Dependencies version (pip freeze)

N/A (Standard Library only)

Expected behavior

jump_search([], 5) should return -1 when given an empty list or sequence, as an empty collection cannot contain the target search item.

Actual behavior

Calling jump_search([], 5) raises an IndexError: list index out of range:

Traceback (most recent call last):
  File "searches/jump_search.py", line 43, in jump_search
    while arr[min(step, arr_size) - 1] < item:
IndexError: list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions