Polynomial Addition using linked list algorithm

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 coefficients who have same variable powers.
Example:

Input: 1st number = 5x2 + 4x1 + 2x0 2nd number = -5x1 - 5x0 Output: 5x2-1x1-3x0 Input: 1st number = 5x3 + 4x2 + 2x0 2nd number = 5x^1 - 5x^0 Output: 5x3 + 4x2 + 5x1 - 3x0

Polynomial Addition using linked list algorithm

1. Introduction

In mathematics, a polynomial is an expression that contains a sum of powersin one or morevariablesmultiplied bycoefficients. A polynomial in one variable,

Polynomial Addition using linked list algorithm
, with constant coefficients is like:
Polynomial Addition using linked list algorithm
. We call each item, e.g.,
Polynomial Addition using linked list algorithm
, a term. If two terms have the same power, we call them like terms.

In this tutorial, we’ll show how to add and multiply two polynomials using a linked list data structure.