Recherche
Regardez la recherche linéaire et la recherche binaire traquer une valeur cible pas à pas : comparaisons, moitiés successives et résultats trouvé/absent.
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.
Comparaison de Recherche
| Algorithme | Meilleur | Moyen | Pire | Espace | Données triées requises ? |
|---|---|---|---|---|---|
| Linear Search | O(1) | O(n) | O(n) | O(1) | No |
| Binary Search | O(1) | O(log n) | O(log n) | O(1) | Yes |