Function that evaluates a polynomial

Assignment Help C/C++ Programming
Reference no: EM13859357

1. Given the following function that evaluates a polynomial whose coefficients are stored in an array: double evaluate(double[] coefficients, int n, double x) double result = coefficients[0]; double power = 1; for (inti = 1; i< n; i++) power = power * x; result = result + coefficients[i] * power; return result; Let n be the length of the array. Determine the number of additions and multiplications that are performed in the worst case as a function of n.

2. Suppose the number of steps required in the worst case for two algorithms are as follows: · Algorithm 1: f(n) = 3n 2 + 5 · Algorithm 2: g(n) = 53n + 9 Determine at what point algorithm 2 becomes more efficient than algorithm 1. Consider the following iterative function for problems 3 and 4. int triangular(int n) { int result = 0; for (inti = 1; i<= n; i ++) result += i; return result; }

3. Rewrite the function triangular using recursion and add preconditions and postconditions as comments.

4. Prove by induction that the recursive function you wrote in the previous problem is correct.

Reference no: EM13859357

Questions Cloud

Prepare an income tax return for the frosts for 2013 : Prepare an income tax return for the Frosts for 2013 - examine the bullets on requirements to add that may pertain to these paragraphs.
Assembly language program to find all prime numbers between : Write a 68000 assembly language program to find all prime numbers between 1 and a specified upper value, inclusive, using the Sieve of Erathosthenes. The specified upper value may be as low as 3 or as high as 1023. Proceed as follows
State the purpose of the function : You may be asked to create a function to solve each of the tasks given below. For each task state the purpose of the function, what the function needs complete the task (input), what the function will send back to the function call (output), and t..
What have you learned about taking exams in college from : What observations can you share about your performance on our midterm?
Function that evaluates a polynomial : 1. Given the following function that evaluates a polynomial whose coefficients are stored in an array: double evaluate(double[] coefficients, int n, double x) double result = coefficients[0]; double power = 1; for (inti = 1; i
Generic binary tree using java generics : In this project you will create a generic binary tree using Java Generics.
How you found the people and food phenomenon : Describe the themes you found in your field notes and give examples that demonstrate each theme
Control system has an operator and a remote machine : A teleoperated control system has an operator and a remote machine. The usual teleoperation system is based on a one-way link to the machine and limited feedback to the operator. However, the use of a two-way coupling will result in a better opera..
Understand the history regarding white males in america : Why is it important to understand the history regarding white males in America? Why is it more difficult for women of color than Caucasian women to rise to top management

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program that prompts for and gets a student name

Write a program that gets 10 numbers and stores then in an array. Then sort (low to high) the number using a function.

  Write a c program that displays a table showing the price

write a c program that displays a table showing the price of silver and gold. the table will have three columns. the

  Write program to declare the array of type float

Write down the c++ program which declares the array of 50 components of type float. Initialize array so that first 25 components are equal to square of the index variable.

  Write a function named read_line

supposes you have a directory whose name is stored in 'specs.file_dir' which contains a file whose name is stored in 'specs.file_name'.

  Write a program that grades an online quiz

write a program that grades an online quiz. The program asks the student to enter his/her answer to 10 multiple-choice questions. The program stores the student's responses in an array and then compares those responses to the correct answers to de..

  Person class that includes fields for last name

Create a Person class that includes fields for last name, first name, and zip code. Include a default constructor that initializes last name, first name, and zip code to "X" if no arguments are supplied. Also include a display function. Write a ma..

  Determine the largest of these ten values

Write a small loop that will determine the largest of these ten values. When the loop completes, the largest number will be in accumulator

  Sum of two squares of natural numbers

The formula "x is a sum of two squares of natural numbers" can be written as ?y?z(x = y × y + z × z).

  Elements that must be included in a loop

What are the three elements that must be included in a loop in order for the loop to successfully perform correctly - What will happen if these statements are not included? Provide examples.

  Implement a function to recursively

Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.

  Implement a function called findmax

Implement a function called findMax that finds the maximum value in a 2¬dimensional array.

  Write a program that will read in 5 numbers

Write a program that will read in 5 numbers and add 10 to the first number, 20 to the second number, and 30 to the third number, 40 to the fourth and 50 to the 50th.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd