Big O and growth
Two independent loops each visit every item in a list. Count the total visits and give the time bound.
Examples
Example 1
Input
n = 4
Expected output
8 visits, O(n)
Example 2
Input
n = 100
Expected output
200 visits, O(n)
Hints and solution
Hint 1
The loops run one after another.
Reveal worked answer
The total is 2n. As the input grows the operation count remains proportional to n, so the tight growth bound is linear and the time is O(n).