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
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.