Multiplication of two polynomials using Linked list
Given two polynomials in the form of linked list. The task is to find the multiplication of both polynomials.
Input: Poly1: 3x^2 + 5x^1 + 6, Poly2: 6x^1 + 8 Output: 18x^3 + 54x^2 + 76x^1 + 48 On multiplying each element of 1st polynomial with elements of 2nd polynomial, we get 18x^3 + 24x^2 + 30x^2 + 40x^1 + 36x^1 + 48 On adding values with same power of x, 18x^3 + 54x^2 + 76x^1 + 48 Input: Poly1: 3x^3 + 6x^1 - 9, Poly2: 9x^3 - 8x^2 + 7x^1 + 2 Output: 27x^6 - 24x^5 + 75x^4 - 123x^3 + 114x^2 - 51x^1 - 18
- In this approach we will multiply the 2nd polynomial with each term of 1st polynomial.
- Store the multiplied value in a new linked list.
- Then we will add the coefficients of elements having the same power in resultant polynomial.
Below is the implementation of the above approach:
1st Polynomial:- 3x^3+6x^1-9 2nd Polynomial:- 9x^3-8x^2+7x^1+2 Resultant Polynomial:- 27x^6-24x^5+75x^4-123x^3+114x^2-51x^1-18
My Personal Notes arrow_drop_up