Code cleanups
[Algorithmic_C.git] / TP2 / exo3 / exo3.c
index 2970b00318fab32b8dad73125dcbdfca62fdd698..29ebcb09ee307295f24dec5d8d69bcedcfbc8a54 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 
 void permuter(int T[], int i1, int i2) {
     int tmp = T[i1];
@@ -13,7 +14,9 @@ void AfficheTab(int T[], int n) {
 }
 
 void TriRapide(int T[], int n) {
-    int pivot = T[0];
+    // The optimal pivot choice is the median value in the tab
+    int index_pivot = arc4random_uniform(n);
+    int pivot = T[index_pivot];
     int TP[n];
     int TG[n];
     int np = 0;