//1DoublePoly (DoubleA[],DoubleXintdegree) { Long inti; Doubleresult = a[0]; DoubleXPWR =x; for(i =1; I <= degree; ++i) {Redsult+ = a[i] *XPWR; XPWR= x *XPWR; } returnresult;}
// horner ' s method double polyh (double X. int degree) { long int I; double result = A[degree]; for (i = degree-1 ; I >= 0 ; --i) {result = A[i] + x * result; return result;}
The same thing, recursion is more magical than iteration. From the code perspective, recursion has fewer additions and multiplication, so in terms of efficiency, recursion is more efficient than iteration ... The low.
Why is it? Assuming that the machine cat and the Fire shadow each episode has the same amount of information, then the inevitable fire shadow broadcast a set takes longer, why? Because the fire shadow each episode has the lengthy previously review, recalls, recalls, then recalls the time. One reason, each iteration is doing the same action, but the material is not the same; And each recursive to the previous steps again, so the first iteration and recursion efficiency difference is not obvious, but when the implementation of the more and more distant, the machine cat all the props out, the fire Shadow is also immersed in the memory of it.
Above.
The calculation of polynomial and the evaluation of Horner polynomial method