Question: 4) [10%] Consider the following algorithm: F(A,B) { // A and B are positive integers k= 1; while B > 0 do { X[k] =B
4) [10%] Consider the following algorithm: F(A,B) { // A and B are positive integers k= 1; while B > 0 do { X[k] =B mod 3 k++ B=B div 3 // only need the quotient temp = A; For j = k-2 downto 1 { temp = temp * temp * temp; if X[j] = 1 temp = temp * A; if X[j] = 2 temp = temp * A*A; print(temp) [2] What will be the output if (i) A = 2, B = 5; (ii) A = 3, B=4 [3%] Guess what the algorithm does. [5%] Give an asymptotically (worst case) tight bound for the running time of the algorithm. Explain your
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
