Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
