Adding Two Polynomials Using Linked List: Courses Suggest An Article
Adding Two Polynomials Using Linked List: Courses Suggest An Article
Custom Search
Courses Login
Suggest an Article
Adding two polynomials using Linked List
Given two polynomial numbers represented by a linked list. Write a function that add these lists means
add the coe cients who have same variable powers.
Example:
Input:
1st number = 5x^2 + 4x^1 + 2x^0
2nd number = 5x^1 + 5x^0
Output:
5x^2 + 9x^1 + 7x^0
Input:
1st number = 5x^3 + 4x^2 + 2x^0
2nd number = 5x^1 + 5x^0
Output:
5x^3 + 4x^2 + 5x^1 + 7x^0
https://www.geeksforgeeks.org/adding-two-polynomials-using-linked-list/ 1/6
4/24/2019 Adding two polynomials using Linked List - GeeksforGeeks
https://www.geeksforgeeks.org/adding-two-polynomials-using-linked-list/ 2/6
4/24/2019 Adding two polynomials using Linked List - GeeksforGeeks
// Driver program
int main()
{
struct Node *poly1 = NULL, *poly2 = NULL, *poly = NULL;
https://www.geeksforgeeks.org/adding-two-polynomials-using-linked-list/ 3/6
4/24/2019 Adding two polynomials using Linked List - GeeksforGeeks
return 0;
}
Output:
Time Complexity: O(m + n) where m and n are number of nodes in rst and second lists respectively.
Please write comments if you nd anything incorrect, or you want to share more information about the
topic discussed above.
Recommended Posts:
Multiplication of two polynomials using Linked list
XOR Linked List – A Memory E cient Doubly Linked List | Set 2
XOR Linked List - A Memory E cient Doubly Linked List | Set 1
Convert singly linked list into circular linked list
Merge a linked list into another linked list at alternate positions
Difference between Singly linked list and Doubly linked list
Convert Singly Linked List to XOR Linked List
Check if a linked list is Circular 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
https://www.geeksforgeeks.org/adding-two-polynomials-using-linked-list/ 4/6
4/24/2019 Adding two polynomials using Linked List - GeeksforGeeks
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
Linked List Sum of Nodes Between 0s
3
Based on 29 vote(s)
Please write to us at [email protected] to report any issue with the above content.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
https://www.geeksforgeeks.org/adding-two-polynomials-using-linked-list/ 5/6
4/24/2019 Adding two polynomials using Linked List - GeeksforGeeks
COMPANY LEARN
About Us Algorithms
Careers Data Structures
Privacy Policy Languages
Contact Us CS Subjects
Video Tutorials
PRACTICE CONTRIBUTE
Company-wise Write an Article
Topic-wise Write Interview Experience
Contests Internships
Subjective Questions Videos
https://www.geeksforgeeks.org/adding-two-polynomials-using-linked-list/ 6/6