Hi guys I have an Algorithm Analysis exam and I was practicing the time complexity and I found this question on the internet.
I tried to solve it but I need you to check if my solution is right or not.
sum = 0 ;
for(i=1; i<=2*n; i++)
sum = sum + 1;
my answer : O(n)
sum = 0 ;
for(i=1; i<=n*n; i++)
sum = sum + 1 ;
my answer: O(n^2)
sum = 0 :
for(i=1; i<=n; i++)
sum = sum + n ;
my answer :O(n^2)
sum = 0 ;
for(i=1; i<=n i++)
for(j=1; j<=i; j++)
sum = sum + i ;
my answer O(n^2)
sum = 0 ;
for(i=1; i<=n; i++)
for(j=1; j<=n; j*=2)
sum = sum + 1 ;