Q. Explain any three methods or techniques of representing polynomials using arrays. Write which method is most efficient or effective for representing the following polynomials.
The three methods or techniques of representing polynomials using arrays is given as follows
(1) if maximum value of exponent of a polynomial is m then describe an array of size m+1 and store coefficient in corresponding index position or location as exponent. Ex:
2x2 +1 is stored as
(2) The one-dimensional array is used to store exponent and coefficient alternatively. Ex: 2x2 +1 is stored as
The size of array needed is 2*n where n is the number of elements in
(3) Use two dimensional arrays or one-dimensional array of structures one for storing exponents and other for co-efficient.
Ex: 2x2 +1 is stored as
The size of arrays is 2*n where n is the number of the elements in polynomial. (i) The second and third methods or techniques are the efficient methods.
For saving 8x100+10x+6 , as in method 1 there is a requirement of 101 integer locations.
(ii) 8x3-7x2+5x+15 for this polynomial any one of the representations can be used, but method or technique 1 will be best as there is only coefficients required to be stored. There are no gaps in the exponents; hence the complete array will be filled with the coefficients.