Operator overloading Polynomials Doubly linked list
Hi , I posted previously this problem, but dint get help , so i m posting it again , hoping i will be helped.
I have created a doubly linked list of polynomials. Now I m done with the basics.
I want to overload + operator.
It add two polynomials list , the first element of the first list searches for all the nodes with the same exponent in the second list. if it finds it , its add them together and insert them in a new list.And else if the exponent is nt matched it inserts both the first and second list nodes in the third list.
Now the problem is with the repetiton of nodes, like in the first iteration 2x^1 and 3x^1
are matched and added but then when the first list searchs for the node of x^2 since 3x^1 doesnt match with it. it inserts it. although it has been added previously and shouldnt be in the list.
I want to delete the nodes when i add them together but having problems with the implementation. Can anybuddy help. Its urgent!!
list operator + (const list& k)
first = head;
f = head;
second = k.head;
s = k.head;
while (first != NULL)
while (second != NULL)
if (first->exponent == second->exponent )
result->coefficient =first->coefficient + second->coefficient;