Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Context: I am learning Dijstra's Algorithm to find shortest path to any node, given the start node. Here, we can use Fibonnacci Heap as Priority Queue. Following is few lines of algorithm:

For each vertex in PriorityQueue{

If $V$ is the number of vertices, the subsequent lookup times in the priority queue will be: $$O(\log V), O(\log V-1), \ldots$$


What would the value of $O(\log V) + O(\log V-1) + O(\log V-2) + .. + O(\log 1)$?

share|cite|improve this question
up vote 12 down vote accepted

You want to find the sum: $$\sum_{n=1}^N{\log{n}} = \log \prod_{n=1}^N {n} = \log(N!)$$ Now, using Stirling's approximation: $$\log N! \sim N\log N$$

share|cite|improve this answer
Nitpick: In the first equation, would the rightmost "log(n!)" be "log(N!)", i.e. 'N' instead of 'n'? (From the summation expression, my interpretation is that, 'n' is a variable, whereas 'N' is a constant.) – Arun Sep 9 '14 at 14:18
@Arun - thanks, corrected. – nbubis Sep 9 '14 at 22:48

$$\log V+\log(V-1)+\log(V-2)+\cdots+\log2+\log1=\log(V!)\sim V\log V$$ The asymptotic $O(V\log V)$ is easy: either one remembers Stirling formula, or one note that the sum on the left is $\leqslant V\log V$ and, keeping only $\frac12V$ terms, $\geqslant\frac12V\log\left(\frac12V\right)\sim\frac12V\log V$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.