Anda di halaman 1dari 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

Anda mungkin juga menyukai