0
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 ответов
+ 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