-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
169 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
nav: | ||
- 1️⃣ Introduction au tri : index.md | ||
- 1️⃣ Tri par insertion : insertion.md | ||
- 1️⃣ Tri par sélection : selection.md | ||
- 1️⃣ Tri par insertion : insertion.md | ||
- 1️⃣ Exercices : exercices.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
help(sorted) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Dans le cas où le minimum apparaît plusieurs fois, on aurait pu aussi retenir la dernière d'entre elles. Le fonctionnement général de l'algorithme aurait été similaire (mais il n'aurait plus été [*stable*](https://fr.wikipedia.org/wiki/Algorithme_de_tri#Tri_stable)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def indice_minimum_depuis(tableau, i): | ||
i_mini = i | ||
for j in range(i + 1, len(tableau)): | ||
if tableau[j] < tableau[i_mini]: | ||
i_mini = j | ||
return i_mini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
assert indice_minimum_depuis([3, 8, 1, 5, 4], 0) == 2, "Erreur en partant de l'indice 0" | ||
assert indice_minimum_depuis([3, 8, 1, 5, 4], 1) == 2, "Erreur en partant de l'indice 1" | ||
assert indice_minimum_depuis([3, 8, 1, 5, 4], 2) == 2, "Erreur en partant de l'indice 2" | ||
assert indice_minimum_depuis([3, 8, 1, 5, 4], 4) == 4, "Erreur en partant de l'indice 4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,3 @@ def tri_selection(tableau): | |
i_mini = j | ||
tableau[i], tableau[i_mini] = tableau[i_mini], tableau[i] | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def tri_selection(tableau): | ||
for i in range(len(tableau) - 1): | ||
i_mini = indice_minimum_depuis(tableau, i) | ||
echange(tableau, i, i_mini) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tableau_0 = [3, 1, 2] | ||
tri_selection(tableau_0) | ||
assert tableau_0 == [1, 2, 3], "Erreur avec [3, 1, 2]" | ||
|
||
tableau_1 = [1, 2, 3, 4] | ||
tri_selection(tableau_1) | ||
assert tableau_1 == [1, 2, 3, 4], "Erreur avec [1, 2, 3, 4]" | ||
|
||
tableau_2 = [-2, -5] | ||
tri_selection(tableau_2) | ||
assert tableau_2 == [-5, -2], "Erreur avec des valeurs négatives" | ||
|
||
tableau_4 = [] | ||
tri_selection(tableau_4) | ||
assert tableau_4 == [], "Erreur avec un tableau vide" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def tri_selection(tableau): | ||
for i in range(len(tableau) - 1): | ||
i_mini = i | ||
for j in range(i + 1, len(tableau)): | ||
if tableau[j] < tableau[i_mini]: | ||
i_mini = j | ||
tableau[i], tableau[i_mini] = tableau[i_mini], tableau[i] | ||
|
||
valeurs = [5, 1, 2] | ||
print("valeurs = ", valeurs) | ||
tri_selection(valeurs) # Appel de la fonction avec l'argument [5, 1, 2] | ||
print("Après appel de la fonction de tri : valeurs = ", valeurs) |
Empty file.
Oops, something went wrong.