## What is the time complexity of the sleep sort?

O(max(input)+n) The complexity just appears awkward to express because most sorting algorithms are data agnostic. Their time scales with the amount of data, not the data itself. FWIW, as pointed out here, this is not a reliable algorithm for sorting data.

## 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