Example #1
0
void quickSort(vector<vector<int> > *edges, int begin, int end, vector<vector<int> > graph) {
	if(begin < end) {
		int pivot = begin ;
	    pivot = partitionner(edges, begin, end, pivot, graph) ;
	    quickSort(edges ,begin, pivot-1, graph) ;
	    quickSort(edges, pivot+1, end, graph) ;
	}
}
Example #2
0
void quickSort(example *tableau, int p, int r,int k) {
    int q;
    if (p < r) {
        q = partitionner(tableau, p, r,k);
        quickSort(tableau, p, q,k);
        quickSort(tableau, q+1, r,k);
    }
}
Example #3
0
File: tris.c Project: maxmouchet/tb
structSondes tri_rapide(int *t, int gauche, int droite) {
  structSondes sonde = { 0, 0, 0 };

  sonde.nb_comparaisons++;
  if (gauche < droite) {
    int pivot = partitionner(t, gauche, droite, &sonde);
    tri_rapide(t, gauche, pivot - 1);
    tri_rapide(t, pivot + 1, droite);
  }

  return sonde;
}
Example #4
0
/**
 * Tri le tableau 'tn' à l'aide de l'algorithme du tri rapide.
 */
void triRapide ( TabNombres tn )
{
  TabNombres gauche, droite;
  int pivot;
  partitionner ( tn, &pivot );
  /* si la taille de la partie gauche est >1 alors récursion */
  if ( pivot > 1 )
    {
      gauche.tab = tn.tab;
      gauche.lng = pivot;
      triRapide( gauche );
    }
  /* On calcule la taille de la partie droite, si >1 alors récursion */
  if ( tn.lng - (pivot + 1) > 1 )
    {
      droite.tab = tn.tab + pivot + 1;
      droite.lng = tn.lng - ( pivot + 1 );
      triRapide( droite );
    }
}
Example #5
0
void triRapideMT(TabNombres tn){
  TabNombres gauche, droite;
  int pivot;
  partitionner ( tn, &pivot );
  /* si la taille de la partie gauche est >1 alors récursion */
  pthread_t thd;
  if ( pivot > 1 )
    {
      gauche.tab = tn.tab;
      gauche.lng = pivot;
      pthread_create(&thd, NULL, (void* (*)(void*))triRapideMTAux, (void*)&gauche);
      pthread_join(thd, NULL);
    }
  /* On calcule la taille de la partie droite, si >1 alors récursion */
  if ( tn.lng - (pivot + 1) > 1 )
    {
      droite.tab = tn.tab + pivot + 1;
      droite.lng = tn.lng - ( pivot + 1 );
      triRapideMT( droite );
    }
}
Example #6
0
void worker(Pile* p){
  TabNombres tn, gauche, droite;
  int pivot;
  depile(p, &tn);
  while(*(tn.tab)){
    partitionner(tn, &pivot);
    if(pivot > 1){
      gauche.tab = tn.tab;
      gauche.lng = pivot;
      empile(p, gauche);
    }if ( tn.lng - (pivot + 1) > 1 ){
      droite.tab = tn.tab + pivot + 1;
      droite.lng = tn.lng - (pivot + 1);
      empile(p, droite);
    }
    depile(p, &tn);
    
  }
  //sleep(2);
  
}