Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4) [10%] Consider the following algorithm: F(A,B) { // A and B are positive integers k= 1; while B > 0 do { X[k] =B

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions