Question: This exercise develops an algorithm to compute ? ? for a given positive integer n . Consider the following algorithm: k = ?(len( n )

This exercise develops an algorithm to compute ?This exercise develops an algorithm to compute ?? for a given positive? for a given positive integer n. Consider the following algorithm:

k = ?(len(n) ? 1)/2?,

integer n. Consider the following algorithm: k = ?(len(n) ? 1)/2?, for

for i = k ? 1 down to 0

do if i = k ? 1 down to 0 do if ?n then ?n then

output m (a) Show that this algorithm correctly computes ? n?. //

output m

(a) Show that this algorithm correctly computes ? n?. // not necessary but if you can solve it please do provide me. Thanks.

(b) In a straightforward implementation of this algorithm, each loop iteration takes time O(len(n)^2), yielding a total running time of O(len(n)^3). Give a more careful implementation, so that each loop iteration takes time O(len(n)), yielding a total running time is O(len(n)^2). // I did not understand this question. I thought big- oh was O(k) for this.

No spam please:

Vn Vn

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!