Solution: Big (O) of Nested Loop with Subtraction
Understand how to calculate the time complexity of nested loops where the outer loop decreases by a step and the inner loop iterates fully. This lesson guides you through step-by-step analysis and identifies the dominant Big O complexity as O(n squared).
We'll cover the following...
We'll cover the following...
Solution #
On line 6 in the outer loop, int i=n; runs once, i>=1; gets executed times and i-=3 executed times. In the inner loop, int j=n; gets executed times in total, j>=0; executes times and j-- gets executed ...