Representation of Polynomials Using Circular Linked List and For The Addition of Two Such Polynomials
Representation of Polynomials Using Circular Linked List and For The Addition of Two Such Polynomials
circular linked list and for the addition of two such polynomials
Algorithm:
Step 1: loop around all values of linked list and follow step 2& 3.
Step 2: if the value of a node’s exponent. is greater copy this node to result node and head
towards the next node.
Step 3: if the values of both node’s exponent is same add the coefficients and then copy the
added value with node to the result.
printf("\nPolynomial 1:\t");
display(head1);
printf("\nPolynomial 2:\t");
display(head2);
printf("\nPolynomial Result:\t");
display(head3);
}
Output:
Coeff = 4
Pow x = 2
Coeff = 2
Pow x = 1
Coeff = -999
Coeff = 2
Pow x = 1
Coeff = 4
Pow x = 0
Coeff = -999