Question: Consider the following pseudo-code: Algorithm ApproxArea Inputs: f (a function) , x 0 , x 1 (floating point numbers) , n (a positive integer) Output:
- Consider the following pseudo-code:
AlgorithmApproxArea
Inputs: f (a function),
x0, x1(floating point numbers),
n(a positive integer)
Output: an approximation of the area underf(x)between x0 and x1 1 sum:= 0
2 delta:= (x1 - x0) / n
3 x:= x0
4 for i = 1 to n-1
5 x:= x + delta
6 sum:= sum + f(x)
7 return (delta/2) * (f(x0) + (2 * sum) + f(x1))
We are interested in the asymptotic complexity ofApproxArea as n grows large. In particular, we want to know T(n) = the number of times we evaluate the functionf, for a given value of n. Give a formula for T(n) and support it using an argument that refers to specific lines (by number) in the pseudo-code above. Remember that in pseudo-code, the bounds of a "for loop" are inclusive.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
