Representation of Polynomial using Array

Consider the two polynomials
A(x) = 2xl000+ 1
B(x) = x4 + 10x3 + 3x2 + 1

  • The above figure shows how these polynomials are stored in the array terms.
  • The index of the first term of A and B is given by start A and start B, while finish A and finish B give the index of the last term of A and B.
  • The index of the next free location in the array is given by avail.
  • For above example, startA=0, finishA=1, startB=2, finish B=5, & avail=6.

One way to represent polynomials in C is to use typedef to create the type polynomial as below:

MAX_TERMS 100 /*size of terms array*/
typedef struct {
  float coef;
  int expon;
}
polynomial;
polynomial terms[MAX - TERMS];
int avail = 0;

Leave a Reply

Your email address will not be published. Required fields are marked *