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 ?? for a given positive integer n. Consider the following algorithm:
k = ?(len(n) ? 1)/2?,
for i = k ? 1 down to 0
do if ?n then
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started