/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q29E Suppose we want to evaluate the ... [FREE SOLUTION] | 91影视

91影视

Suppose we want to evaluate the polynomial P(x) = a0 + a1x + a2x2 + ... + anxn at point x.

  1. Show that the following simple routine, known as Horner鈥檚 rule, does the job and leaves the answer in z.
    z = an
    for I = n-1 down to 0 :
    z = zx + ai
  2. How many additions and multiplications does this routine use, as a function of n ? Can you find a polynomial for which an alternative method is substantially better?

Short Answer

Expert verified
  1. The Horner鈥檚 rule, evaluates the polynomial and stores the answer in the z
  2. One multiplication and one addition per loop. The Horner鈥檚 rule is the optimal method to find the polynomial.

Step by step solution

01

Explain polynomial

A polynomial expression is the algebraic form of expression that has the degrees for the variables. The polynomial expression has the same variable with multiple degrees.

02

Show that the following simple routine, known as Horner’s rule, does the job and leaves the answer in z.

(a)

Consider the Horner鈥檚 ruleas follows,

z = an

for i = n - 1 down to 0 :

z = zx + ai

Let the loop invariant be 2 , when looping to i, then

zi=ai+ai+1x+ai+2x2+anxn-1, Then on the twenty first loop,

zi-1=zix+ai-1=ai-1+ai+1-1x+ai+2-1x2+...anxn-(i-1)=ai-1+aix+ai+1x2+...anxn-(i-1)

Therefore, it has been proved that the Horner鈥檚 rule compute the polynomials and store at z

03

How many additions and multiplications does this routine use and which alternative method is substantially better

(b)

Consider the Horner鈥檚 ruleas follows,

z = an

for i = n -1 down to 0 :

z = zx + ai

One multiplication and one addition per loop is performed, in total n multiplications and n additions are performed in the given scheme.

No alternative method calculates polynomial better than the Horner鈥檚 rule.

Therefore, One multiplication and one addition per loop. The Horner鈥檚 rule is the optimal method to find the polynomial.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91影视!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Section 2.2 describes a method for solving recurrence relations which is based on analyzing the recursion tree and deriving a formula for the work done at each level. Another (closely related) method is to expand out the recurrence a few times, until a pattern emerges. For instance, let鈥檚 start with the familiar T(n)=2T(n/2)+o(n). Think of o(n) as being role="math" localid="1658920245976" <cnfor some constant , so: T(n)<2T(n/2)+cn. By repeatedly applying this rule, we can bound T(n) in terms of T(n/2), then T(n/4), then T(n/8), and so on, at each step getting closer to the value of T(.) we do know, namely .

T(1)=0(1).

T(n)2T(n/2)+cn2[2Tn/4+cn/2]+cn=4T(n/4)+2cn4[2Tn/8+cn/4]+2cn=8T(n/8)+3cn8[2Tn/16+cn/8]+3cn=16T(n/16)+4cn

.

.

.

A pattern is emerging... the general term is

T(n)2kT(n/2k)+kcn

Plugging in k=log2n, we get T(n)nT(1)+cnlog2n=0(nlogn).

(a)Do the same thing for the recurrence T(n)=3T(n/2)+0(n). What is the general kth term in this case? And what value of should be plugged in to get the answer?(b) Now try the recurrence T(n)=T(n-1)+0(1), a case which is not covered by the master theorem. Can you solve this too?

You are given two sorted lists of size mandn. Give an O(logm+logn)time algorithm for computing the k th smallest element in the union of the two lists.

A linear, time-invariant system has the following impulse response:


(a) Describe in words the effect of this system.

(b) What is the corresponding polynomial

In our median-finding algorithm (Section 2.4), a basic primitive is the split operation, which takes as input an array S and a value V and then divides S into three sets: the elements less than V , the elements equal to V , and the elements greater than V . Show how to implement this split operation in place, that is, without allocating new memory.

How many lines, as a function of n (in (.)form), does the following program print? Write a recurrence and solve it. You may assume is a power of . function f (n) if n > 1:

print_line (鈥樷榮till going鈥欌)

f (n/2)

f (n/2)

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.