Resource · Guide or article
Jump Search
Jump search on a sorted array: probe every m-th element, then scan linearly inside the right block.
Reviewed
Open the original: Jump Search (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
Like Binary Search, Jump Search (or Block Search) is a searching algorithm for sorted arrays. The basic idea is to check fewer elements (than linear search) by jumping ahead by fixed steps or skipping some elements in place of searching all elements. For example, suppose we have an array arr[] of size n and block (to be jumped) of size m. Then we search at the indexes arr[0], arr[m], arr[2 * m], ..., arr[k * m] and so on. Once we find the interval arr[k * m] x arr[(k+1) * m], we perform a linear search operation from the index k * m to find the element x. What is the optimal block size to be skipped? In the worst case, we have to do n/m jumps and if the last checked value is greater than the element to be searched for, we perform m - 1 comparisons more for linear search. Therefore the total number of comparisons in the worst case will be ((n/m) + m - 1). The value of the function ((n/m) + m - 1) will be minimum when m = √n. Therefore, the best step size is m = √n.
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Reference
What it covers
- Indexing pattern arr[0], arr[m], arr[2m] and the final linear scan.
- Derivation of the best block size, m = sqrt(n), from the worst-case comparison count.
- Time complexity stated as O(sqrt(n)).
How to use it
PrepKit study advice, not a claim made by the source.
Reproduce the block-size derivation on paper, then implement it and count comparisons for n = 100 using m = 10.
Scope and limitations
Short, with no code walkthrough or exercises; references are GeeksForGeeks and Wikipedia.
Access and format
English README, readable free on GitHub in trekhleb/javascript-algorithms (MIT license).
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/search/jump-search/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.