atquick_sort.c
contents ::
  address.c
  atquick_sort.c
  bits.c
  countspace.c
  ctof.c
  hextoint.c
  hist.c
  indexof.c
  itob.c
  linkage.c
  lzw.c
  maxval.c
  merge.c
  merge_sort.c
  peof.c
  pointer.c
  quick2.c
  quick.c
  quick_sort.c
  reverse.c
  rftoc.c
  rmultiblank.c
  rtabs.c
  squeeze.c
  structoo.c
  syscall.c
  tempfunc.c
  tfc.c
  word.c

/* Quick sort with pointers updated for tail recursion */
void tquicksort(int *a, int lo, int hi){
  while( hi > lo ) {
    int left, right, median, temp;
    left=lo;
    right=hi;
    median=*(a+((lo+hi)/2));
    while(right >= left){
      
      while(*(a+left) < median) left++;
      
      while(*(a+right) > median) right--;
      if(left > right) break;
      
      temp=*(a+left);
      *(a+left)=*(a+right);
      *(a+right)=temp; //swap
      
      left++;
      right--;
    }

    
    tquicksort(a, lo, right);// divide and conquer
    lo=left;
  }
}/*quicksort*/

James Little