Busca
Veja a busca linear e a binária localizarem um valor alvo passo a passo: comparações, divisões pela metade e resultados de acerto ou erro.
Linear SearchScan the array one element at a time until the target appears.Binary SearchHalve the search window each step until the target is found.
Comparação de Busca
| Algoritmo | Melhor | Médio | Pior | Espaço | Exige dados ordenados? |
|---|---|---|---|---|---|
| Linear Search | O(1) | O(n) | O(n) | O(1) | No |
| Binary Search | O(1) | O(log n) | O(log n) | O(1) | Yes |