2 ms·
This is a non-trivial problem, generally complexity analysis is done on paper, based on some idealised version of an algorithm. In practice implementation issue
by jheriko 17y ago
This is a non-trivial problem, generally complexity analysis is done on paper, based on some idealised version of an algorithm. In practice implementation issues will make it difficult to extrapolate asymptotic behaviour for small n.
For instance an algorithm with O(log n) multiplications and O(n^2) additions will be dominated by the multiplications for small n, and may mislead an analysis tool into believing the asymptotic time complexity of the algorithm to be O(log n), rather than O(n^2), since the additions will dominate for very large n, simply because at some point a n^2 > m log n, where m is the run time of addition and a is the run-time of addition.
This becomes even more difficult if addition and multiplication have non-constant run-time as well (e.g. multi-precision ints).