retagged by
1,272 views

2 Answers

0 votes
0 votes

Using Horner's method, it will take o(n) time.

int horner(int poly[],int n,int x)
{
    int result=poly[0];
    for(int i=1;i<n;i++)
    result=result*x+poly[i];
    return result;
}

using naive method:

y=0
for(i=0 to n do
yi=x
for(i=1 to n do
yi=yi*x
end for
y=y+ai*yi;
end for

using double for loop,so o(n^2)  time.

 

Related questions

1 votes
1 votes
2 answers
1
5 votes
5 votes
1 answer
2
0 votes
0 votes
4 answers
4