Reputation: 373
Suppose that I have two computational complexities :
O(k * M(n))
- computational complexity of modular exponentiation, where k
is number of exponent bits , n
is number of digits , and M(n)
is computational complexity of the Newton's division algorithm.
O(log^6(n))
- computational complexity of an algorithm.
How can I determine which one of these two complexities is less "expensive" ? In fact notation M(n)
is that what confusing me most .
Upvotes: 5
Views: 725
Reputation: 10579
First, for any given fixed n
, just put it in the runtime function (sans the Landau O, mind you) and compare.
Asymptotically, you can divide one function (resp its Landau term) by the other and consider the quotient's limit for n
to infinity. If it is zero, the function in the nominator grows properly, asymptotically weaker than the other. If it is infinity, it grows properly faster. In all other cases, the have the same asymptotic grows up to a constant factor (i.e. big Theta). If the quotient is 1
in the limit, they are asymptotically equal.
Upvotes: 1
Reputation: 12006
Okay, according to this Wikipedia entry about application of Newton method to division , you have to do O(lg(n))
steps to calculate n
bits of division. Every step employs multiplication and subtraction, so has bit complexity O(n^2)
in case we employ simple "schoolbook" method.
So, complexity of first approach is O(lg(n) * n^2)
. It's asymptotically slower than second approach.
Upvotes: 0