Skip to content · ⁨コンテンツへスキップ⁩

Binary search

English

Binary search

The array is sorted. Return the index of target, or -1 if it isn't there. Binary search halves the range each step: check the middle element, then keep looking in just the left or right half. Far faster than scanning every element.

日本語

二分探索

この配列は整列済みです。targetのインデックスを返します。存在しない場合は-1を返します。二分探索では、各ステップで範囲を半分にし、中央の要素を確認した後に左または右の半分のみを探し続けます。すべての要素をスキャンするよりも遥かに高速です。

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP