This is boggling my mind.
- The square root of
100 secondsis10 seconds - The square root of
100000 millisecondsis approximately316.23 milliseconds 10 secondsdoes not approximately equal316.23 milliseconds
Do I have a fundamental problem with my unit conversions or my ability to punch numbers on a calculator, or am I just not thinking through the problem with the right mindset?
The reasoning behind the question is that I made an incorrect prediction for the run time of an algorithm after I reduced its complexity. Previously, the algorithm had n operations and ran for 100 seconds, where n is the size of the input. Now, my algorithm has sqrt(n) operations. I predicted that the algorithm would run in 10 seconds, and was surprised when it ran in 0.375 seconds.
Note: For answering purposes, assume that the overhead time associated with running my program is negligible compared to the variable time it takes to run my algorithm. In other words, assume that the run-time is almost entirely dependent on the size of n, for any n of sufficient size.
No, the square root of $100\,\mathrm s$ is $10\,\mathrm s^{1/2}$, not $10\,\mathrm s$.
One $\mathrm s^{1/2}$ equals approximately $31.623\,\mathrm{ms}^{1/2}$.
Just like a square meter is not the same unit as a meter (and a square kilometer is certainly not 1000 square meters), a $\sqrt{\text{second}}$ is not the same as a second.
In the case of running time, the speedup from $n$ to $\sqrt n$ operation depends on what $n$ is -- just knowing that it sums up to $100$ seconds is not in itself helpful without knowing how much time one operations takes.
Also, what you have are probably asymptotic bounds, $O(n)$ and $O(\sqrt n)$, so there are unknown constant factors involved anyway, which means you have (given) far too little information to predict the running time of the new algorithm.