Question: The function SuperPower receives two inputs, x and n, and should returnx 4n-2 x is a real number and n is positive integer. SuperPower(x, n)
The function SuperPower receives two inputs, x and n, and should returnx4n-2x is a real number and n is positive integer.
SuperPower(x, n)
If n = 1, then Return(x^2)
y := SuperPower(x, n-1)
Return( ? )
The correctness of algorithm SuperPower(x, n) is proven by induction on n. What would be proven in the base case?
SuperPower(1, n) returns 1
SuperPower(x, 1) returnsx2
SuperPower(x, 0) returnsx-2
SuperPower(0, n) returns 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
