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

Mergesort Two Chains of POLY_CELLs:

    // ******************************************** //
    // mergesort a chain of FLOAT_POLY_CELLs        //
    // ******************************************** //
FLOAT_POLY_CELL* FLOAT_POLY::mergesort(FLOAT_POLY_CELL* A)
{
  FLOAT_POLY_CELL *temp1,*temp2;
  temp1 = A;
  if(temp1==NULL) return NULL;
  else if (temp1->next==NULL) return temp1; 
  else{
    //at least 2 elements in list
    temp2 = split(temp1);
    return merge(mergesort(temp1),mergesort(temp2));
    }
}



Jim Peterson
1999-04-22