Skip to content

Commit a3babb5

Browse files
committed
Ultimate changes on this Sort
1 parent 14d916d commit a3babb5

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

146 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Tri-de-selection/Algorithm-Iteratif.algo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ DEBUT
66
ENTIER: v <- 0
77
ENTIER: pos <- 0
88
ENTIER: min <- 0
9-
POUR i variant de 0 à N-2
9+
POUR i variant de 0 à La Longueur du Tableau -1
1010
pos <- i
11-
POUR v variant de i+1 à N-1
11+
POUR v variant de i+1 à la Longueur du Tableau
1212
SI T(v) < T(pos), alors pos <- v
1313
FINSI
1414
FINPOUR

Tri-de-selection/src/Iteratif.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public static int[] selectedSort(int[] tableau) {
2626
pos = v;
2727

2828
comparaisons+=1;
29-
affectations+=1;
29+
affectations+=2;
3030
}
3131
comparaisons+=1;
3232
}
3333
min = tableau[pos];
3434
tableau[pos] = tableau[i];
3535
tableau[i] = min;
3636
echanges += 1;
37-
affectations += 3;
37+
affectations += 4;
3838
}
3939
return tableau;
4040
}
@@ -48,8 +48,8 @@ public static void main(String[] args) {
4848
// Tableau de test
4949

5050
// int[] tableau = {10,9,8,7,6,5,4,3,2,1};
51-
// int[] tableau = {1,2,3,4,5,6,7,8,9,10};
52-
int[] tableau = { rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100) };
51+
int[] tableau = {1,2,3,4,5,6,7,8,9,10};
52+
// int[] tableau = { rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100), rand.nextInt(100) };
5353

5454
System.out.println("Tableau d'avant fonction : " + Arrays.toString(tableau));
5555
System.out.println("Tableau après fonction : " + Arrays.toString(selectedSort(tableau)));
@@ -66,9 +66,7 @@ public static void main(String[] args) {
6666

6767
public static void stat(int min,int max, int step, int nbr) {
6868
int i;
69-
comparaisons = 0;
70-
echanges = 0;
71-
affectations = 0;
69+
7270
for ( i = 1 ; i <= nbr ; i++) {
7371
int Tab[] =new Random().ints(min).toArray();
7472
selectedSort(Tab);

0 commit comments

Comments
 (0)