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

Binary search

English

Binary search

The array is sorted and has n elements. Return the index of target, or -1 if it isn't present. Keep lo and hi bounds, check the middle each step, and discard the half that can't contain the target.

日本語

二分探索

この配列はソート済みで、n 個の要素があります。target のインデックスを返し、存在しない場合は -1 を返します。lo と hi の境界を保ち、ステップごとに中央をチェックして、ターゲットが含まれ得ない半分を除外します。

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

IGCSE, A-Level & AP