Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. public void trierRapide()
  2. {
  3. trierRapide(0,nbElt-1);
  4. }
  5.  
  6. private int partition(int deb,int fin)
  7. {
  8. int compt = deb;
  9. int pivot = tab[deb];
  10.  
  11. for(int i=deb+1;i<=fin;i++)
  12. {
  13. if (tab[i]<pivot)
  14. {
  15. compt++;
  16. permuter(compt,i);
  17. }
  18. }
  19.  
  20. permuter(deb,compt);
  21.  
  22. return compt;
  23. }
  24.  
  25. private void trierRapide(int deb,int fin)
  26. {
  27. if(deb<fin)
  28. {
  29. int positionPivot=partition(deb,fin);
  30. trierRapide(deb,positionPivot-1);
  31. trierRapide(positionPivot+1,fin);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement