Published by Dimitris Kougioumtzis · Updated
Search an ascending array; the visualization sorts your input first.
Probe block endpoints to locate a candidate block, then scan that block; square-root jumps balance both costs.
When to use Jump search
Comparing block probing with midpoint search.
Choosing an alternative
Binary search usually needs fewer probes on random-access arrays.
Worked example: input and state changes
Example input
38, 12, 65, 8, 43, 27, 91, 19 | 43
These checkpoints follow the actual example timeline. State details show the stored values and decisions; use the visualization to inspect every intervening step.
Step 0: Initial state.
State at this checkpoint
{ "values": [ 8, 12, 19, 27, 38, 43, 65, 91 ], "active": [] }Step 1: Jump to next block.
State at this checkpoint
{ "values": [ 8, 12, 19, 27, 38, 43, 65, 91 ], "active": [ 1 ] }Step 3: Search within candidate block.
State at this checkpoint
{ "values": [ 8, 12, 19, 27, 38, 43, 65, 91 ], "active": [ 4 ] }Step 4: Search within candidate block.
State at this checkpoint
{ "values": [ 8, 12, 19, 27, 38, 43, 65, 91 ], "active": [ 5 ] }Step 5: Found 43 at index 5.
State at this checkpoint
{ "values": [ 8, 12, 19, 27, 38, 43, 65, 91 ], "active": [ 5 ] }
Expected final state
Found 43 at index 5.
Complexity and input bounds
Family: Searching. Time complexity: O(√n).
Space complexity: O(1) auxiliary space.
Working-space bounds describe algorithm state and any explicitly noted output, excluding the visualization's saved timeline. Recording frames can use more memory than running the function alone. Here n is sequence length, V and E are vertex and edge counts, and other parameters refer to the named input dimensions.
2–24 comma-separated integers between 0 and 99. Follow with | target.
The playground validates these limits before starting. Downloaded functions are callable implementations, with parameter and output-buffer contracts in their comments; they do not all repeat the playground's input validation.
Common mistakes and limitations
Clamp the final short block before reading its endpoint.
Further reading
For background on algorithm analysis and the JavaScript function interface:
- MIT OpenCourseWare: algorithm design and analysis foundations
- MDN: JavaScript function parameters and return values
Editorial and testing approach · Browse all algorithm guides
Complete JavaScript implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 | // Requires ascending input. Returns the found index, or -1. Reference snippets assume validated playground inputs. Fixed scratch buffers have 256 slots. Sorting variants may use a different traversal strategy than the animation. function algorithm(a, n, target) { let block = 1; while ((block + 1) * (block + 1) <= n) { block++; } let start = 0; let end = block; while (start < n) { let last = end - 1; if (last >= n) { last = n - 1; } if (a[last] >= target) { break; } start = end; end += block; } for (let i = start; i < end && i < n; i++) { if (a[i] == target) { return i; } } return -1; } |
Source
Primary research source for the algorithm or its underlying method. The playground is a bounded teaching implementation, not the publication's original program.
- Jump searching
Ben Shneiderman (1978). Research paper.