dominik
Aktives Mitglied
Hi,
ich bin heute auf diese Stelle in einem Artikel gestoßen: https://www.aleksandrhovhannisyan.c...ptimize-later/#1-not-all-inputs-scale-in-size
Da drin heißt es:
Demzufolge sei die Komplexität hier
Viele Grüße
Dominik
ich bin heute auf diese Stelle in einem Artikel gestoßen: https://www.aleksandrhovhannisyan.c...ptimize-later/#1-not-all-inputs-scale-in-size
Da drin heißt es:
Javascript:
// Version 2
const allowedValues = ['a', 'b', 'c', 'd'];
if (allowedValues.includes(value)) {
}
In this case, the array always has a fixed size of four elements. We're not passing in a dynamic array as a dependency to our algorithm—it's just a static, hard-coded array of items that we look up in an if statement.
Demzufolge sei die Komplexität hier
O(1)
anstatt O(n)
. Kann man das tatäschlich so argumentieren? Viele Grüße
Dominik