next up previous contents
Next: Find the Degree of Up: Sorting a Polynomial With Previous: Mergesort Two Chains of

Mergesort a Polynomial:

    // ****************************** //
    // merge sort for FLOAT_POLY      //
    // ****************************** // 
 
void FLOAT_POLY::mergesort(){head = mergesort(head);}






\subsection{Building a Polynomial:}

\small
\begin{verbatim}
    // ************************************** //
    //  build a polynomial                    //
    // ************************************** //
void FLOAT_POLY::build_list(FLOAT *A,int number)
{
  int i = -1;
  FLOAT_POLY_CELL *temp,*again;
  if(!(A==NULL)){
    head = new FLOAT_POLY_CELL();
    head->element = A[++i];
    head->power = (unsigned)number- 1 -i;
    again = head;
    while(i<number-1){
      again->next = new FLOAT_POLY_CELL();
      again->next->element = A[++i];
      again->next->power = (unsigned int)number- 1 -i;
      again = again->next;
      }
    }
}



Jim Peterson
1999-04-22