1. ## Horner's Algorithm

Hello,

I am a college student, and I got a question wrong on the last test. I was wondering if anyone could give me the answer, as I am stumped and frustrated.

HERE IT IS:

Horner's Algo can be used to evaluate a polynomial at a point O(n) time.

SEE ATTACHMENT (COULDN"T GET FORMATTING IN THIS WINDOW)
MANY SUPER AND SUBSCRPITS

2. (COULDN"T GET FORMATTING IN THIS WINDOW)
That's what [code] [/code] tags are for.

3. Code:
```double routineC(double coeffs[], int size, double x) {
int I;  // intended to be i?
double y = 0;
for(i=0;i<=size;i++){  // i is undeclared
y += coeffs[i] * pow(x,i);
}
}```

4. might want to return y after the for loop too.

5. And come to think of it
Code:
`for(i=0;i<=size;i++){`
you probably want < there, since you're using it to access the array.

6. ## Tru

You are correct with your changes, sorry I guess I typed too fast...But it still leaves the rest of the problem.

7. The rest of the problem? You mean the code that you haven't written yet?

8. That's not Horner's algorithm. This is.

Code:
```double horners(double * poly, int size, double x) {
double ret = 0.0;

double * end = poly + size;

while (poly != end) {
ret *= x;
ret += *poly;
++poly;
}

return ret;
}```