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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!