Exponentiation

I had planned to present the classic ``exponentiation by repeated squaring algorithm'' separately today. But then I realized that it's exactly the same as recursive Russian!

Homework: Write a recursive algorithm for computing ab (where both a and b are positive integers). Analyze its correctness and efficiency. The number of recursive calls it makes should be logarithmic.


next up previous
Next: Divide and Conquer Up: RECURSION Previous: Concrete Example