0% found this document useful (0 votes)
67 views

Polynomial Representation Using Arrays

This document discusses representing polynomials using arrays. It explains that polynomials should be stored in arrays in descending order of exponents. It then provides an algorithm to add two polynomials stored as arrays to produce a resultant polynomial array. The algorithm uses nested while loops to iterate through the arrays, compare exponents, and add or copy over terms to the result array.

Uploaded by

robinpt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Polynomial Representation Using Arrays

This document discusses representing polynomials using arrays. It explains that polynomials should be stored in arrays in descending order of exponents. It then provides an algorithm to add two polynomials stored as arrays to produce a resultant polynomial array. The algorithm uses nested while loops to iterate through the arrays, compare exponents, and add or copy over terms to the result array.

Uploaded by

robinpt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Polynomial representation using

arrays

Store polynomial in the descending order of the exponents

Algorithm

input: two polynomials A & B


output: resultant polynomial C
data structure: array

Steps

While i<n1 and j<n2

While i<n1
c[0][k]=a[0][i]

if a[1][i]=b[1][j]
c[0][k]=a[0][i]+b[0][j]

c[1][k]=a[1][i]

c[1][k]=a[1][i]

increment i and k

increment i, j, and k
else if a[1][i]>b[1][j]
c[0][k]=a[0][i]
c[1][k]= a[1][i]
increment i and k
else
c[0][k]=b[0][j]
c[1][k]=b[1][j]
increment j and k
endif
endwhile

endwhile

While j<n2
c[0][k]=b[0][j]
c[1][k]=b[1][j]
increment j and k

endwhile

You might also like