Homework Solution: Power(y: number; z: non-negative integer)…

    Power(y: number; z: non-negative integer) 1. if z==0 then return 1 2. if z is odd then 3. return (Power(y*y, z/2)*y) comment: z/2 is integer division; note the parentheses else 4. return Power(y*y, z/2) comment: z/2 is integer division Draw the Recursion Tree of Power(5,5)

    Expert Answer

    Power(y: number; z: non-negative integer)

    1. if z==0 then repay 1

    2. if z is over then

    3. repay (Power(y*y, z/2)*y) comment: z/2 is integer division; still n ess the parentheses

    else

    4. repay Power(y*y, z/2) comment: z/2 is integer division

    Draw the Recursion Tree of Power(5,5)

    Expert Apology