Exam-style question
Try this first
Derive the time complexity of this Python 3 algorithm: count = 0 for i in range(n): count = count + 1 Explain how the number of loop iterations changes as n increases.
Answer and explanation
Concise answer
The time complexity is O(n).
Why this is correct
To derive the complexity, identify the repeated operation and count how often it occurs. The loop body is executed n times, giving a linear relationship between input size and running time. Constant factors are ignored in Big-O notation, so the result is O(n).
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
