C++ Linked list problem, computer science homework help

Get perfect grades by consistently using www.assignmentgeeks.org. Place your order and get a quality paper today. Take advantage of our current 20% discount by using the coupon code GET20


Order a Similar Paper Order a Different Paper

According to the file that i uploaded, I have to write add polynomial function

so far I wrote like this and it does not work

how can I fix this code?

void add (List &polyZ, List &polyF, List &poly G)

{

   Node *pN_Z,*pN_F;

   int icoeff,ideg;

   

   head=ptrn= ptrp = NULL;

   pN_Z =Z.head;

   pN_F =F.head;

   

   while(pN_Z!=NULL && pN_F=NULL)

   {

      if(pN_Z->ideg==pN_F->ideg)  // deg is equal

      {

icoeff=pN_Z->icoeff+pN_F->icoeff;

ideg=pN_Z-> ideg;

pN_Z= pN_Z->next;

pN_F= pN_F->next;

      }

      else if(pN_Z->ideg > pN_F->ideg)

      {

icoeff = pN_Z->icoeff;

ideg = pN_Z->ideg;

pN_Z = pN_Z->next;

      }

      else if(pN_Z->ideg <pN_F->ideg)

      {

icoeff = pN_F->icoeff;

ideg = pN_F->ideg;

pN_F = pN_F->next;

      }

      ptrn=new node;

      if(head==NULL)

 head =ptrn;

      ptrn->icoeff= icoeff;

      ptrn-> ideg= ideg ;

      ptrn-> next=NULL;

      ptrp->next=ptrn;

      ptrp=ptrn;

   } // End of While

   if(pN_Z==NULL)

   {

      while(pN_F!=NULL)

      {

icoeff =pN_F->icoeff;

ideg = pN_F->ideg;

pN_F= pN_F->next;

     ptrn=new node;

if(head==NULL)

   head=ptrn;

ptrn->icoeff=icoeff;

ptrn->ideg=ideg;

ptrn->next=NULL;

ptrp->next=ptrn;

ptrp=ptrn;

      }

   }

   else if(pN_F==NULL)

   {

      while(pN_Z!=NULL)

      {

icoeff =pN_Z->icoeff;

ideg = pN_Z->ideg;

pN_Z= pN_Z->next;

ptrn=new node;

if(head==NULL)

   head=ptrn;

ptrn->icoeff=icoeff;

ptrn->ideg=ideg;

ptrn->next=NULL;

ptrp->next=ptrn;

ptrp=ptrn;

      }

   }

}  // End of addition

Writerbay.net

Do you need help with this or a different assignment? We offer CONFIDENTIAL, ORIGINAL (Turnitin/LopesWrite/SafeAssign checks), and PRIVATE services using latest (within 5 years) peer-reviewed articles. Kindly click on ORDER NOW to receive an A++ paper from our masters- and PhD writers.

Get a 15% discount on your order using the following coupon code SAVE15


Order a Similar Paper Order a Different Paper