Time complexity for a loop? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Time complexity for a loop?

I’m still confused about time complexity. Is a code O(1) if the number of times it loops is less than the Length of an array or is it O(n)?

13th Sep 2019, 4:23 PM
Jamie Charles
1 Antwort
+ 2
It depends on type of algorithm, quick sort, binary search, etcetera it is all about the expression, and nested loops. Jamie Charles
13th Sep 2019, 6:42 PM
Prantik Sarkar
Prantik Sarkar - avatar