From: Jerome Benoit Date: Sun, 5 Mar 2017 09:13:43 +0000 (+0100) Subject: TP 2 exo3: randomly choose the pivot in quick sort X-Git-Url: https://git.piment-noir.org/?p=Algorithmic_C.git;a=commitdiff_plain;h=569df90ab9f7e584fe5b8812320f8461c999647f TP 2 exo3: randomly choose the pivot in quick sort Signed-off-by: Jerome Benoit --- diff --git a/TP2/exo3/exo3.c b/TP2/exo3/exo3.c index f070f1f..29ebcb0 100644 --- a/TP2/exo3/exo3.c +++ b/TP2/exo3/exo3.c @@ -1,4 +1,5 @@ #include +#include void permuter(int T[], int i1, int i2) { int tmp = T[i1]; @@ -14,7 +15,8 @@ void AfficheTab(int T[], int n) { void TriRapide(int T[], int n) { // The optimal pivot choice is the median value in the tab - int pivot = T[0]; + int index_pivot = arc4random_uniform(n); + int pivot = T[index_pivot]; int TP[n]; int TG[n]; int np = 0;