Skip to content

Commit 14d916d

Browse files
authored
Merge pull request #10 from CodingFactory-Repos/feature/sortedSelection-recursive
All Tests + Operations + Recursive Algorithm
2 parents 3964ccc + 011bd83 commit 14d916d

5 files changed

Lines changed: 35 additions & 14 deletions

File tree

Tri-a-bulles-optimise/src/Iteratif.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public static void main(String[] args) {
1616
Random rand = new Random();
1717

1818
// Tableau de test
19-
// 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) };
20-
int[] tableau = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
21-
// System.out.println(Arrays.toString(triBulle(tableau)));
19+
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) };
20+
// int[] tableau = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
21+
System.out.println(Arrays.toString(triBulle(tableau)));
2222

2323
stat(10, 20, 5, 10);
2424

Tri-de-selection/Algorithm-Iteratif.algo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ DEBUT
1515
Min <- T(pos)
1616
T(pos) <- T(i)
1717
T(i) <- Min
18-
FINSI
19-
RETOURNER Tableau(T)
18+
2019
FINPOUR
20+
RETOURNER Tableau(T)
2121
FIN
2222

Tri-de-selection/Algorithm-Recursif.algo

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
// Correspond à la fonction Tri Sélection Récursif
2+
DEBUT
23
ENTRÉE
34
ENTIER: i
45
VARIABLE
56
ENTIER: v <- 0
67
ENTIER: pos <- 0
7-
ENTIER: min <- 0
8-
pos <- i
9-
SI T(v) < T(pos) ALORS pos <- v
8+
ENTIER: min <- 0
9+
SI i < La Longueur du Tableau -1 ALORS pos <- i
10+
POUR v variant de i+1 à N-1
11+
SI T(v) < T(pos), alors pos <- v
1012
FINSI
13+
FINPOUR
1114
Min <- T(pos)
1215
T(pos) <- T(i)
1316
T(i) <- Min
14-
SI i < N-2 && v < N-1 ALORS Appeler fonction TriSélectionRec()
17+
FINSI
18+
SI i < La Longueur du Tableau -1 ALORS Appeler fonction TriSélectionRec()
1519
FINSI
1620
RETOURNER Tableau(T)
1721
FINFONCTION

Tri-de-selection/src/Iteratif.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class Iteratif {
44
public static float echanges = 0;
55
public static float comparaisons = 0;
66
public static float affectations = 3*echanges;
7+
public static float operations;
78

89

910

@@ -40,19 +41,24 @@ public static int[] selectedSort(int[] tableau) {
4041
public static void main(String[] args) {
4142
// write your code here
4243
// Clear console
43-
System.out.print("\033[H\033[2J");
44+
System.out.flush();
4445

46+
Random rand = new Random();
47+
4548
// Tableau de test
46-
int[] tableau = {1,2,3,4,5,6,7,8,9,10};
49+
4750
// int[] tableau = {10,9,8,7,6,5,4,3,2,1};
4851
// int[] tableau = {1,2,3,4,5,6,7,8,9,10};
49-
50-
System.out.println("Tableau de test : " + Arrays.toString(selectedSort(tableau)));
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) };
53+
54+
System.out.println("Tableau d'avant fonction : " + Arrays.toString(tableau));
55+
System.out.println("Tableau après fonction : " + Arrays.toString(selectedSort(tableau)));
5156
System.out.println("Comparaisons : " + comparaisons);
5257
System.out.println("Echanges : " + echanges);
5358
System.out.println("Affectations : " + affectations );
59+
System.out.println("Opérations" + (echanges + affectations + comparaisons));
5460

55-
stat(10,20,5,10);
61+
// stat(10,20,5,10);
5662

5763
}
5864

Tri-insertion/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@
1414
<natures>
1515
<nature>org.eclipse.jdt.core.javanature</nature>
1616
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1634827583121</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
1728
</projectDescription>

0 commit comments

Comments
 (0)