Búsqueda
Observa cómo la búsqueda lineal y la binaria localizan un valor objetivo paso a paso: comparaciones, mitades y resultados de acierto o fallo.
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.
Comparación de Búsqueda
| Algoritmo | Mejor | Promedio | Peor | Espacio | ¿Requiere datos 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 |