Consider the following algorithm: Algorithm Calc(a, n): Input: two integers, a and n Output: ? k leftarrow 0 b leftarrow 1 while k
Expert Answer
Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Consider the following algorithm: Algorithm Calc(a, n): Input: two integers, a and n Output: ? k leftarrow 0 b leftar…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
5 a) Its computing . Basically in each iteration of while loop b is multiplied by a and its done n times so result is
b) Time complexity of above algorithm considering constant time in doing multiplication is O(n) as while loop runs n time doing constant work.