title: How can I modify the pivot choice for this quick sort algorithm?
body: <p>I would like to modify the listed quick sort algorithm to choose the pivot choice as 1) A random element in the array. 2) The median of the first middle and last elements in the array.
  ====UPDATE====
  Also how can I implement a timing mechanism to time the runtime for each algorithm?</p>
  
  <pre><code>void QuickSort1(long *L, int first, int last)
  {
     int SplitPoint;  /* Value to Split list around */
  
     if( first &lt; last )
     {
        /* Use first element as pivot (for splitting) */
        SplitPoint = first;                 /* assign SplitPoint to 1st index */
        Split(L, first, last, &amp;SplitPoint); /* Split List around SplitPoint */
        QuickSort1(L, first, SplitPoint-1);  /* Sort 1st section of list */
        QuickSort1(L, SplitPoint+1, last);   /* Sort 2nd section of list */
     }
  }
  
  void Split(long *L, int first, int last, int *SplitPoint)
  /* Splits a list around SplitPoint such that all values to the left of
     SplitPoint are &lt; than SplitPoint and all values to the right of
     SplitPoint are &gt;= SplitPoint */
  {
     int x;            /* Key */
     int unknown;      /* index of unknown value */
  
     x = L[*SplitPoint];   /* assign x to value at SplitPoint */
     Swap( &amp;L[*SplitPoint], &amp;L[first] ); 
     *SplitPoint = first; 
  
     /* Loop walks through unknown portion of list */
     for ( unknown = first+1; unknown &lt;= last; ++unknown)
     {
        /* If unknown value is &lt; SplitPoint Value, then: */
  #ifdef TAKE_COUNT
           comparison_count++;
  #endif
        if( L[unknown] &lt; x ) {
           ++ (*SplitPoint);                     /* SplitPoint is incremented */
           Swap( &amp;L[*SplitPoint], &amp;L[unknown] ); /* values are swapped*/
        }
     }
     /* Original value which was being split upon is swapped with the current
        SplitPoint to put it in correct position */
     Swap( &amp;L[first], &amp;L[*SplitPoint] );
  }
  
  int FindMedian(long *L, int A, int B, int C)
  /* Receives array and three respective indices in the array. */
  /* Returns the index of the median. */
  {
     if (L[A] &lt; L[B])
       if (L[B] &lt; L[C])       /*  A &lt; B &lt; C  */
         return (B);
       else
         if (L[A] &lt; L[C])         /*  A &lt; C &lt; B  */
       return (C);
         else
       return (A);            /*  C &lt; A &lt; B  */
     else
       if (L[A] &lt; L[C])           /*  B &lt; A &lt; C  */
         return (A);
       else
         if (L[B] &lt; L[C])     /*  B &lt; C &lt; A  */
       return (C);
         else
       return (B);            /*  C &lt; B &lt; A  */
  }
  
  void Swap(long *a, long *b)
  /* This function uses call by reference to switch two elements.*/
  {
     long temp;    /* temporary variable used to switch. */
  
     temp = *a;   /* temp = 1st # */
     *a = *b;     /* 1st # = 2nd # */
     *b = temp;   /* 2nd # = temp */
  }
  </code></pre>
  
  <p>How am I able to modify this for the listed pivot choices.  They must also be added as additional menu options for the program.</p>