Question 9
Back to Exercise
Both loops run from 0 to n − 1. How many times does the inner body execute?
- A n
- B 2n
- C n × n Correct
- D n + n²
Correct Answer: Option C
The inner loop runs n times for each of the n outer passes: n × n = n² – O(n²) time. Doubling n makes such code about four times slower.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!