repositories
/
Algorithmic_C.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
711cfc8
)
TP 2 exo3: randomly choose the pivot in quick sort
author
Jerome Benoit
<jerome.benoit@sap.com>
Sun, 5 Mar 2017 09:13:43 +0000
(10:13 +0100)
committer
Jerome Benoit
<jerome.benoit@sap.com>
Sun, 5 Mar 2017 09:13:43 +0000
(10:13 +0100)
Signed-off-by: Jerome Benoit <jerome.benoit@sap.com>
TP2/exo3/exo3.c
patch
|
blob
|
blame
|
history
diff --git
a/TP2/exo3/exo3.c
b/TP2/exo3/exo3.c
index f070f1f493a789901b1710074a6764a2e1e9fee3..29ebcb09ee307295f24dec5d8d69bcedcfbc8a54 100644
(file)
--- a/
TP2/exo3/exo3.c
+++ b/
TP2/exo3/exo3.c
@@
-1,4
+1,5
@@
#include <stdio.h>
+#include <stdlib.h>
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;