Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following pseudo-code: Algorithm ApproxArea Inputs: f (a function) , x 0 , x 1 (floating point numbers) , n (a positive integer) Output:

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete Mathematics and Its Applications

Authors: Kenneth H. Rosen

7th edition

0073383090, 978-0073383095

More Books

Students also viewed these Computer Network questions

Question

How can good packaging help a product? LO.1

Answered: 1 week ago