Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I'm really new to time complexity, could you justify the answer from one sentence to another Problem 1. Consider the problem of evaluating a polynomial
I'm really new to time complexity, could you justify the answer from one sentence to another
Problem 1. Consider the problem of evaluating a polynomial The input is defined by a value x and a polynomial p represented as an array A = [ao, ai, . . ., 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 scratch 1: function NaivE(x, A) 2:answer- 0 3: n length of A 4 for i from 0 to n do aux - ]1 for i from 1 to i do 7: 8: answer-answer + aux * Ai] return answeir The second one, is based on Horner's rule for polynomial evaluation. 1: function HORNEr(X,A) 2: answer =0 3: nlength of A 4 for i from n to 0 do answer - A[i] +answer*x return answer a) Using O-notation, upperbound the running time of Naive b) Using O-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 HornerStep 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