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 + 135x^3 + 114x^2 + 75x^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^2 + 5x^1 + 6 2nd Polynomial:- 6x^1 + 8 Resultant Polynomial:- 18x^3 + 54x^2 + 76x^1 + 48
- Adding two polynomials using Linked List
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Merge a linked list into another linked list at alternate positions
- Difference between Singly linked list and Doubly linked list
- Convert singly linked list into circular linked list
- Check if a linked list is Circular Linked List
- Convert Singly Linked List to XOR Linked List
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
- Partitioning a linked list around a given value and If we don't care about making the elements of the list "stable"
- Length of longest palindrome list in a linked list using O(1) extra space
- Rotate the sub-list of a linked list from position M to N to the right by K places
- Multiply two polynomials
- Program to add two polynomials
- Flattening a Linked List
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.