Skip to content · ⁨Saltar al contenido⁩

Searching: linear and binary · ⁨Búsqueda: lineal y binaria⁩

English

Finding a value

  • A common job is to search: is a value in an array, and where?
  • The usual answer is the index where we found it, or -1 if it is not there.
  • We learn two ways: linear search (works on any array) and binary search (needs a sorted array, but is much faster).
Español

Encontrar un valor

  • Un trabajo común es buscar: ¿hay un valor en un array y, ¿dónde está?
  • La respuesta habitual es el índice donde se encontró, o -1 si no está.
  • Aprendemos dos formas: búsqueda lineal (funciona con cualquier array) y búsqueda binaria (necesita un array ordenado, pero es mucho más rápida).

Handout · ⁨Material⁩

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

IGCSE, A-Level & AP