[Math] merge sort vs insertion sort time complexity

algorithmsasymptoticslogarithms

How do I solve exercise 1.2-2 from

Introduction to Algorithms 3rd Edition, Author: Thomas H. Cormen

Excercise 1.2-2

Would I need to set both sides equal to each other and solve for n?

Best Answer

If you haven't already, you should prove that for all integers $k>0$, if you have an integer $N>0$ such that $2^{N}>N^{k}$, then, for all $n\geq N$, $2^{n}>n^{k}$ (or, more generally, there is an integer $N$ such that $2^{n}>p\left(n\right)$ for all $n\geq N$ where $p$ is any polynomial). This is a simple induction argument, and should be done in any algorithms course. From there, you set up the problem like so:

You're given that $8n^{2}<64n\lg n$. So, after a bit of algebra (you can do this part), we get it in to the form $2^{n}<n^{8}$. We have to find all $n>0$ such that this holds, and so, once we have found $N$ such that $2^{N}<N^{8}$ and $2^{N+1}\geq\left(N+1\right)^{8}$, we will know that all integers in the interval $1\leq n\leq N$ satisfy the problem. You can easily find $N$ with a calculator.

(Hint: $N$ is bigger than 40 but less than 45)

Related Question