in Algorithms retagged by
1,259 views
2 votes
2 votes

Using Horner method and Brute force what will be the Time Complexity of 4x4+7x3-2x2+3x+6

in Algorithms retagged by
1.3k views

2 Answers

0 votes
0 votes
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.

 

1 comment

Thanks
0
0

Related questions