Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1. Consider the problem of evaluating a polynomial p(x) = anx + an-1x+ . . . + a1 x + a0. The input is

image text in transcribed

Problem 1. Consider the problem of evaluating a polynomial p(x) = anx" + an-1x"+ . . . + a1 x + a0. The input is defined bv a value x and a polynomial p represented as an array A - [ao, a1,..., an] of coefficients. The output should be p(x) Assuming each addition and multiplication takes O(1) time, you are to analyze the complexity of two algorithms for this task. The first one, is a naive strategy that computes each term of the polynomial from scratclh 1: function NAivE(x, A) answer 0 3: length of A 2 4: for i from 0 to n do for j from 1 to i do T. answer - answer + aux * Ali return answer The second one, is based on Horner's rule for polynomial evaluation function HORNER(X,A) 1: 2: 3: n=length of A 4: for i from n to 0 do answer = 0 answer - A[i] + answer* x return answer a) Using O-notation, upperbound the running time of NaIvE. b) Using -notation, lowerbound the running time of NAIVE to show that your upperbound is in fact asymptotically tight. c) Using O-notation, upperbound the running time of Horner

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions