本文へスキップ

リソース · ガイド・記事

Jump Search

ソート済み配列でのジャンプ探索を扱います。m 個おきの要素を調べ、該当するブロックの中を線形に走査します。

確認日

元のサイトを開く: Jump Search (元のサイトを新しいタブで開きます)

ロードマップに追加

取り組んでいるロードマップにこのリソースを追加できます。自分用の追加リソースとして表示され、ロードマップの手順は変わらず、記録した手順数にも数えられません。

出典コンテンツの言語:英語

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 の概要

この概要は PrepKit 編集部がソースリポジトリをもとに執筆・確認したもので、リソース本文の引用ではありません。

対象
ソースにレベルの記載はありません
形式
リファレンス

扱っている内容

  • arr[0]、arr[m]、arr[2m] というインデックスの進め方と、最後の線形走査。
  • 最悪の場合の比較回数から、最適なブロックサイズ m = sqrt(n) を導く過程。
  • 時間計算量は O(sqrt(n)) とされています。

使い方

PrepKit の学習アドバイスであり、ソースの主張ではありません。

ブロックサイズの導出を紙の上で再現し、実装して、n = 100、m = 10 の場合の比較回数を数えてください。

範囲と制約

短く、コードの解説や演習はありません。参考文献は GeeksForGeeks と Wikipedia です。

利用方法と形式

GitHub の trekhleb/javascript-algorithms(MIT ライセンス)にある英語の README で、無料で読めます。

PrepKit が 2026/10/02 に確認しました。 リソースの出典のコミット: 85293e3e2b88

この概要の根拠
  • src/algorithms/search/jump-search/README.md

この項目を掲載しているページ

PrepKit ニュースレターを受け取る

任意です。PrepKit の利用には必要ありません。

メールアドレスの取り扱いについて