I reading "Introduction to Algorithms", where I asked solve exercise (ex. below)
"Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size $n$, insertion sort runs in $8n^2$ steps, while merge sort runs in $64n \lg {n}$ steps. For which values of $n$ does insertion sort beat merge sort?"
So I peek solution:
$8n^2<64n\log_2(n) \implies n^2<8n\log_2(n) \implies n\leq43$
Please somebody explain me how from $n^2<8n\log_2(n)$ get to $n\leq43$.
You are looking for the maximum $n$ such that $n \lt 8\log_2 n$. Generally we need to do numeric approximation for expressions like this that mix logs and polynomials. You can use the fact that the log is slowly increasing and just try. We can start by trying powers of $2$ so the log is easy to take. $n=32$ gives $32 \lt 40$, which is true. $n=64$ gives $64 \lt 48$, which is false. Now keep going, just cutting the interval in half each time. This is the bisection method, which is easy to understand and program, but takes more evaluations of the function than other approaches. You can also graph the two sides and look for the intersection.