Is complexity O(log(n) + log(n/2) + log(n/4) + log(n/8) + ... + log(2)) = O(log(n))?

Viewed 10132

As homework, I was asked to write an algorithm in O(log(n)) and I could calculate the complexity of the one I wrote as O(log(n) + log(n/2) + log(n/4) + log(n/8) + ... + log(2)).

I think it's rather O(n) since it's roughly log(n)*O(log(n)) = O(n). But I was not sure about it. I know homework questions are not welcome here, but I really don't know another way to find out what complexity it is. Googling didn't help me.

To specify: n in N and n = pow(2, c), c in N

2 Answers
Related