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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Discrete Mathematics and Its Applications
Authors: Kenneth H. Rosen
7th edition
0073383090, 978-0073383095
Students also viewed these Computer Network questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App