Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd FastPow #1791
Add FastPow #1791
Comments
This PR tries to solve TheAlgorithms#1791 implementing a faster algorithm. The old algorithm used recursion which takes O(n) time to run, being n the exponent. This new algorithm uses the paradigm of `divide and conquer` with a time complexity of O(log n) and space complexity of O(1).
Fixes TheAlgorithms#1791 The old algorithm used recursion which takes O(n) time to run, being n the exponent. This new algorithm uses the paradigm of `divide and conquer` with a time complexity of O(log n) and space complexity of O(1). This is a reimplementation of https://www.geeksforgeeks.org/write-a-c-program-to-calculate-powxn/ but this will only work with positive exponent since the signature of the function only allow natural numbers.
Fixes TheAlgorithms#1791 The old algorithm used recursion which takes O(n) time to run, being n the exponent. This new algorithm uses the paradigm of `divide and conquer` with a time complexity of O(log n) and space complexity of O(1). This is a reimplementation of https://www.geeksforgeeks.org/write-a-c-program-to-calculate-powxn/ but this will only work with positive exponent since the signature of the function only allow natural numbers.
Currently implemented
pow
function will return "time limit exceeded". So, we need to add a new function to make a better execution time.