Skip to main content

LateNights Textbook

A Practical Introduction to Programming

Get Started

Or, try out a random code snippet below:

import math

def jump_search(data, item):
    step = round(math.sqrt(len(data)))
    i = 0
    while i < len(data) and data[i] <= item:
        i += step
    for i in range(i - step, i):
        if data[i] == item:
            return i
    return -1


data = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
print(jump_search(data, 55))