for 1 to n
for j=1 to 3
for i=j to n
count++
My answer: O(n^2)
Please correct me if I am wrong. Thank You
edit: The Innermost loop runs for O(n) as well as the Outermost loop. But what about j=1 to 3 ?
edit 2: From what I have learned, Space complexity can be calculated if there are -
- Variable Declaration
- Data Structures
- Allocations
- Function Call
But there are none of those in the above code. So what will be the space complexity ?