Question: 6. Consider the following pseudo code: function Compute(a: real number, n: positive integer) if n= 1 then p=a else p = a + Compute(a, n-1)

6. Consider the following pseudo code: function Compute(a: real number, n: positive integer) if n= 1 then p=a else p = a + Compute(a, n-1) return p a) Find out what this function computes given a and n. Verify your answer by induction. b) Write down the complexity function T(n) of the above algorithm as a recurrence relation. c) Find big- (big Theta) complexity of the algorithm. Measure the complexity in terms of comparison and addition operations
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
