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:

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

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!