mardi 26 juillet 2016

Are C/C++ library functions and operators the most optimal ones?

So, at the divide & conquer course we were taught: Karatsuba multiplication Fast exponentiation Now, given 2 positive integers a and b is operator::* faster than a karatsuba(a,b) or is pow(a,b) faster than int fast_expo(int Base,int exp) { if (exp==0) { return 1; } if (exp==1) { return Base } if (exp%2==0) { return fast_expo(Base,exp/2)*fast_expo(Base,exp/2); } else { return base*fast_expo(Base,exp/2)*fast_expo(Base,exp/2); } } I ask this because I wonder if they have just a teaching purpose or they are already base implemented in the C/C++ language

Aucun commentaire:

Enregistrer un commentaire