Skip to content · ⁨Pular para o conteúdo⁩

Searching: linear and binary · ⁨Busca: linear e binária⁩

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).
Português

Encontrando um valor

  • Uma tarefa comum é pesquisar: se um valor está em um array, e onde?
  • A resposta usual é o índice onde o encontramos, ou -1 se não estiver lá.
  • Aprendemos duas formas: busca linear (funciona em qualquer array) e busca binária (precisa de um array ordenado, mas é muito mais rápida).

Handout · ⁨Material de apoio⁩

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP