Skip to content

Commit 3952b08

Browse files
committed
💁‍♀️ - Add Algorithm
1 parent ad2613d commit 3952b08

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

Tri-à-bulles_optimisé/Algorithm.algo

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@
22
FONCTION ENTIER TriBulle(tableau: t)
33
// Définir les variables
44
VARIABLE
5-
INT: passages
6-
BOOLEAN: désordre
5+
INT: n
6+
BOOLEAN: echange
77
// Début de l'algorithme
88
DEBUT
9-
// Début de la boucle
10-
REPETER
11-
désordre <- FAUX
12-
POUR i VARIANT DE 1 A n - 1 - passage FAIRE
13-
SI a[i] > a[i+1] ALORS
14-
echanger a[i] ET a[i+1]
15-
désordre <- VRAI
9+
// Initialisation
10+
n <- TAILLE(tableau)
11+
echange <- VRAI
12+
temp
13+
14+
// Tant qu'il y a echange
15+
TANT QUE echange EST VRAI FAIRE
16+
// Initialisation
17+
echange <- FAUX
18+
19+
// On parcourt le tableau
20+
POUR i DE 1 A n FAIRE
21+
// On compare les éléments suivants
22+
SI tableau[i] > tableau[i+1] ALORS
23+
// On échange les valeurs
24+
temp <- tableau[i]
25+
tableau[i] <- tableau[i+1];
26+
tableau[i+1] <- temp;
27+
echange <- VRAI
1628
FIN SI
1729
FIN POUR
18-
passages <- passages + 1
19-
20-
FINREPETER
30+
FIN TANT QUE
31+
RETOURNE tableau
2132
FIN
22-
FINFONCTION
33+
FIN FONCTION
34+
// al

0 commit comments

Comments
 (0)