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 Answers
+ 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