リソース · ガイド・記事
Binary Search
ソート済み配列での二分探索を短く定義しています。範囲を半分にしていく多くの面接問題の出発点です。
確認日
元のサイトを開く: Binary Search (元のサイトを新しいタブで開きます)このトピックを練習二分探索 の問題で練習用面接官を開きます。
ロードマップに追加
取り組んでいるロードマップにこのリソースを追加できます。自分用の追加リソースとして表示され、ロードマップの手順は変わらず、記録した手順数にも数えられません。
出典コンテンツの言語:英語
Read this in other languages: Português brasileiro. Español. In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. If the search ends with the remaining half being empty, the target is not in the array. Time Complexity: O(log(n)) - since we split search area by two for every next iteration.
PrepKit の概要
この概要は PrepKit 編集部がソースリポジトリをもとに執筆・確認したもので、リソース本文の引用ではありません。
- 対象
- ソースにレベルの記載はありません
- 形式
- リファレンス
扱っている内容
- 中央の要素と比較するたびに、残りの範囲の半分を捨てる仕組み。
- 残りの範囲が空になった場合、つまり目的の値が存在しない場合の扱い。
- 時間計算量は O(log(n)) とされています。
使い方
PrepKit の学習アドバイスであり、ソースの主張ではありません。
反復版と再帰版を書き、空の配列、要素1つの配列、存在しない値でテストしてください。
範囲と制約
非常に簡潔で、境界のずれ(off-by-one)の説明も、下限・上限を求める変形も、練習問題もありません。Wikipedia と YouTube へのリンクがあります。ポルトガル語版とスペイン語版があります。
利用方法と形式
GitHub にある英語の無料 README です(trekhleb/javascript-algorithms、MIT)。
PrepKit が 2026/10/02 に確認しました。 リソースの出典のコミット: 85293e3e2b88
この概要の根拠
- src/algorithms/search/binary-search/README.md
関連する準備資料
PrepKit による学習の提案です。雇用主の推薦や、面接で出る質問の予測ではありません。
- Binary Search
確認済みの問題と資料の関連付けです。
- Find Minimum In Rotated Sorted Array
確認済みの問題と資料の関連付けです。
- First Bad Version
確認済みの問題と資料の関連付けです。
この項目を掲載しているページ
PrepKit ニュースレターを受け取る
任意です。PrepKit の利用には必要ありません。