Advertisement
Fede

Untitled

Dec 22nd, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. void bubble_sort(int * V, int N, int * perm){
  2.  int * iter = 0;
  3.  Boolean iter_without.swap = FALSE;
  4.  Boolean swap_found;
  5.  
  6.  while(iter_without.swap == FALSE){
  7.   for(count=0, swap_found=FALSE; count<N-iter-1; count++){
  8.    if(v[perm[count]] > v[perm[count+1]]){
  9.     swap(perm, count, count+1);
  10.     swap_found = TRUE;
  11.    }
  12.   }
  13.   if(swap_found==FALSE)
  14.    iter_without.swap = TRUE;
  15.   else
  16.    iter++;
  17.  }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement