Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
Time complexity question
Is anyone able to help with the TC of the following operation. Assume that BI and CI are the same length as C: for i in range(0, len(C)): Ā Ā Ā Ā if BI[i]==0 and CI[i]>=1: Ā Ā Ā Ā Ā Ā return True
2 Respostas
+ 1
I havenāt done time complexity in awhile, but linear iteration is O(n). Iām also assuming that Bl and Cl are simply arrays and therefore have random access.
Range() probably takes O(n) and Iāve heard that len() is O(1) since Python automatically stores the length of iterable data structures.
So, to sum up, Iād say it would resemble linear time: O(n).
+ 1
Thanks, I appreciate that