Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include"vectordinamico.h"
  4. unsigned long choose_pivot(unsigned long i, unsigned long j){
  5.     return((i+j)/2);
  6. }
  7. void quicksort(vectorP *pvector, unsigned long beg, unsigned long end){
  8.     if(end>beg+1){
  9.         TELEMENTO piv= recuperar(*pvector,beg);
  10.         unsigned long l= beg+1,r=end;
  11.         while(l<r){
  12.             if(recuperar(*pvector,l)<=piv)
  13.                 l++;
  14.             else{
  15.                 r--;
  16.                 swap(pvector,l,r);
  17.             }
  18.         }
  19.         l--;
  20.         swap(pvector,l,beg);
  21.         quicksort(pvector,beg,l);
  22.         quicksort(pvector,r,end);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement