Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are given an input integer array P = [ a 0 , a 1 , a 2 , . . . an ] of
You are given an input integer array P a a a an of length n that stores the coefficients of an n degree polynomial p and an integer value x Your goal
is to compute the value of px a ax ax ax anxn for an input x You may
assume that all elementary integer operations take O time.
Consider the following algorithm, and convince yourself that it correctly evaluates the polynomial.
def polyEvalPx:
ans
for i in rangen: n
term Pi
for j in rangei:
term term x
ans ans term
return ans
What is the runtime of this algorithm? Choose between stating the answer as bigTheta or bigO as appropriate, choosing the most restrictive answer when possible.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started