Skip to content · ⁨Saltar al contenido⁩

Binary search · ⁨Búsqueda binaria⁩

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.

Español

Búsqueda binaria

El array está ordenado. Devuelve el índice de target, o -1 si no se encuentra. La búsqueda binaria reduce a la mitad el rango en cada paso: se revisa el elemento central y luego se continúa buscando solo en la mitad izquierda o derecha. Es mucho más rápida que examinar cada elemento uno por uno.

Log in or create account · ⁨Iniciar sesión o crear cuenta⁩

IGCSE, A-Level & AP