I've been trying to understand time complexity and space complexity by writing my own snippets of code and solving them. Can you see if I'm correct?
for(int i=1; i<=n; i*=2) c = i+8;
for(int j=n; j>0 ; j/=2) a[j] = 8;
I think the time complexity is $O(log_2n)$ and the space complexity is $O(n)$.
for(int i = 1; i<=n;i*=2)
for(int j=n ; j>0 ; j/=2)
a[j] = 8;
In this case, the time complexity is $O((log_2n)^2)$ and the space complexity is $O(n)$.
What do you think?