next up previous contents
Next: Merging Two Halves: Up: Sorting a Polynomial With Previous: Sorting a Polynomial With

Splitting a Polynomial Into Two Halves:

    // ************************************************ //
    // split a FLOAT_POLY list into the set             //
    // of odd indices and even indices                  //
    // ************************************************ //
FLOAT_POLY_CELL* FLOAT_POLY::split(FLOAT_POLY_CELL* A)
{
  //every other element of the chain A is stored in the new
  //chain ``second'' and so A is smaller by about half.
  //output incoming list    

  FLOAT_POLY_CELL *temp1,*temp2;
  temp1 = A;
  if(temp1==NULL) return (NULL);
  else if(temp1->next==NULL) return (NULL);
  else{
    temp2 = temp1->next;
    temp1->next = temp2->next;
    temp2->next = split(temp2->next);
    return(temp2);
    }
}



Jim Peterson
1999-04-22