Question: 2. Analyzing iterative algorithms. (7 points) Consider the procedure that returns value of [n/b] for n0,b1. DIV (n,b) (Non-negative Integet) 1. k=n 2. D=0 3.

 2. Analyzing iterative algorithms. (7 points) Consider the procedure that returns

2. Analyzing iterative algorithms. (7 points) Consider the procedure that returns value of [n/b] for n0,b1. DIV (n,b) (Non-negative Integet) 1. k=n 2. D=0 3. while kb : 4. k=kb 5. D=D+1 6. return D (a) Circle each statement below that is a loop invariant of the algorithm: ( 3 points) - After t iterutions, kn - After t iterations, Dk - After t iferutions, D= t (b) Consider the loop invariant: Aftert iterations, (nk)/b=D Correctness of algorithm: ( 4 points) Assuming that this loop invariant is true, show that when the algorithm terminates, n/b1

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!