Question

Problem 1. (1 point) The SolEc algorithm shown below is used with a = 0, b...

Problem 1. (1 point) The SolEc algorithm shown below is used with a = 0, b = 2 and n = 3. What is the value of c on the line Write c?

Function z <- f (x)

z = 85−99x + 15x2 − x3;

End Function

algorithm SolEc

Read a, b, n;

For i From 1 To n Do

c = (a + b) / 2;

Write a, ",", c, ",", b;

If f (a) * f (c) <0 Then

b = c;

If not

a = c;

End yes

End To Write c;

End Algorithm

c =

Homework Answers

Answer #1

Here,

1)Function z <- f (x)

2)z = 85−99x + 15x2 − x3;

3)End Function

4)algorithm SolEc

5)Read a, b, n;

6)For i From 1 To n Do

7)c = (a + b) / 2;

8)Write a, ",", c, ",", b;

9)If f (a) * f (c) <0 Then

10)b = c;

11)If not

12)a = c;

13)End yes

14)End To Write c;

15)End Algorithm

In line 6) , The loop executes 3 times:

and final value of c= (0 + 2)/2 =1

Then program prints:

0,1,2

For , f(a) , programs goes to function call, with x=0; and returns 85 as f(a).

For , f(b) , programs goes to function call, with x=2; and returns 0 as f(b).

So f(a) * f(b) = 0 which is not less than 0.

So, else part of if statement gets executed. i.e. a=c = 1

So, The value of c on Line Write c is 1.

Hope you find this helpful.

Please provide an upvote , if you like the solution.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question 4.5 Consider the fragment in Algorithm 4.8 shown below. Algorithm 4.8 sum = 0; for...
Question 4.5 Consider the fragment in Algorithm 4.8 shown below. Algorithm 4.8 sum = 0; for (i =1; i <=f(n); i ++) sum += i; Here f(n) is a function call. Give a simple and tight Big-Oh upper bound on the running time of Algorithm 4.8, as a function of n, on the assumption that (a) the running time of f(n) is O(n), and the value of f(n) is n!. (b) the running time of f(n) is O(n), and the...
Give a recursive algorithm to solve the following recursive function.    f(0) = 0;    f(1)...
Give a recursive algorithm to solve the following recursive function.    f(0) = 0;    f(1) = 1; f(2) = 4; f(n) = 2 f(n-1) - f(n-2) + 2; n > 2 Solve f(n) as a function of n using the methodology used in class for Homogenous Equations. Must solve for the constants as well as the initial conditions are given.
1). Consider the following function and point. f(x) = x3 + x + 3;    (−2, −7) (a)...
1). Consider the following function and point. f(x) = x3 + x + 3;    (−2, −7) (a) Find an equation of the tangent line to the graph of the function at the given point. y = 2) Consider the following function and point. See Example 10. f(x) = (5x + 1)2;    (0, 1) (a) Find an equation of the tangent line to the graph of the function at the given point. y =
The following is Algorithm 8 from §5.4. Note that it uses the following definition of the...
The following is Algorithm 8 from §5.4. Note that it uses the following definition of the fibonacci sequence: fn = fn−1 + fn−2, f1 = 1, f0 = 0. procedure iterative fibonacci(n: nonnegative integer) if n = 0 then return 0 else x := 0 y := 1 for i := 1 to n − 1 do z := x + y x := y y := z end for return y end if end procedure Prove this algorithm is...
1) Write an algorithm to calculate the sum of the following series:           Sum =x-x3/3! +...
1) Write an algorithm to calculate the sum of the following series:           Sum =x-x3/3! + x5/5! – x7/7! +…….     Stop when the                     term<0.0001.    2) An internet service provider charges its subscribers per month as follows:           Data usage (n), in gbs           charges (NIS)           0.0<n<=1.0                                250           1.0<n<=2.0                                500           2.0<n<=5.0                              1000           5.0<n<=10.0                            1500                   n>10                                 2000          Write a C program to read the usage(n) from a file and print the charges to be paid by...
How to measure the time complexity of an algorithm? Identify an important operation in the algorithm...
How to measure the time complexity of an algorithm? Identify an important operation in the algorithm that is executed most frequently. Express the number of times it is executed as a function of N. Convert this expression into the Big-O notation. A. For each of the three fragments of code, what is its worst-case time complexity, in the form "O(…)". (Use the given solution to the first problem as a model)                 //----------------- This is a sample problem – solved ------...
F(x,y) = (x2+y3+xy, x3-y2) a) Find the linearization of F at the point (-1,-1) b) Explain...
F(x,y) = (x2+y3+xy, x3-y2) a) Find the linearization of F at the point (-1,-1) b) Explain that F has an inverse function G defined in an area of (1, −2) such that that G (1, −2) = (−1, −1), and write down the linearization to G in (1, −2)
Below is the problem that I have and here is the code that I have in...
Below is the problem that I have and here is the code that I have in c++. Can someone help me on what I am doing wrong or the correct code. A teacher has asked all her students to line up according to their first name. For example, in one class Amy will be at the front of the line, and Yolanda will be at the end. Write a program that prompts the user to enter the number of students...
1. a) Find a value of x other than 0 such that the vectors <-3x, 2x>...
1. a) Find a value of x other than 0 such that the vectors <-3x, 2x> and <4, x> are perpendicular b) find the domain of the vector function r (t) = <sin (t), ln (t), 1 / (t-1)> c) Determine if the sequence converges or diverges, if it converges determines its limit ln (2 + e ^ n) / 2020n d) Find the point (a, b, c) where the line x = 1-t, y = t, z = 1...
Problem 10. Let F = <y, z − x, 0> and let S be the surface...
Problem 10. Let F = <y, z − x, 0> and let S be the surface z = 4 − x^2 − y^2 for z ≥ 0, oriented by outward-pointing normal vectors. a. Calculate curl(F). b. Calculate Z Z S curl(F) · dS directly, i.e., evaluate it as a surface integral. c. Calculate Z Z S curl(F) · dS using Stokes’ Theorem, i.e., evaluate instead the line integral I ∂S F · ds.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT