## Finding Big O of the Harmonic Series

This follows easily from a simple fact in Calculus: and we have the following inequality: Here we can conclude that S = 1 + 1/2 + … + 1/n is both Ω(log(n)) and O(log(n)), thus it is Ɵ(log(n)), the bound is actually tight.

## What is O(log(n!)), O(n!), and Stirling’s approximation?

O(n!) isn’t equivalent to O(n^n). It is asymptotically less than O(n^n). O(log(n!)) is equal to O(n log(n)). Here is one way to prove that: Note that by using the log rule log(mn) = log(m) + log(n) we can see that: log(n!) = log(n*(n-1)*…2*1) = log(n) + log(n-1) + … log(2) + log(1) Proof that O(log(n!)) … Read more

## What is O(log(n!)) and O(n!) and Stirling Approximation

O(n!) isn’t equivalent to O(n^n). It is asymptotically less than O(n^n). O(log(n!)) is equal to O(n log(n)). Here is one way to prove that: Note that by using the log rule log(mn) = log(m) + log(n) we can see that: log(n!) = log(n*(n-1)*…2*1) = log(n) + log(n-1) + … log(2) + log(1) Proof that O(log(n!)) … Read more

## Computational complexity of Fibonacci Sequence

You model the time function to calculate Fib(n) as sum of time to calculate Fib(n-1) plus the time to calculate Fib(n-2) plus the time to add them together (O(1)). This is assuming that repeated evaluations of the same Fib(n) take the same time – i.e. no memoization is used. T(n<=1) = O(1) T(n) = T(n-1) … Read more

## How to solve T(n)=4T(sqrt(n/2))+n^(3/2)

The time function is: We can make this substitution: And thus: Now the i + 1th expansion of the time function gives a term: And the termination index of i, assuming T(0) = 0: And so the time complexity is given by: Unfortunately, this is non-analytical (no elementary function representation). Instead, however, we can make … Read more