diff --git a/slides/cours_17.md b/slides/cours_17.md index 14f14edbe203c24a49d0c98389f0b6375503a137..a2c6d9d3ea852da4ca6fba0319eb7261542504db 100644 --- a/slides/cours_17.md +++ b/slides/cours_17.md @@ -335,7 +335,7 @@ arbre suppression(arbre, clé) . . . ``` -arbre insertion(tree, clé) +arbre insert(tree, clé) si est_vide(tree) retourne nœud(clé) @@ -494,7 +494,7 @@ graph TD; **But:** Transformer l'arbre en tas. -* On commence à l'indice $N/2 = 5$: `4`. +* On commence à l'indice $N/2-1 = 4$: `4`. * `7 > 4` (enfant `>` parent). * intervertir `4` et `7`. @@ -536,7 +536,7 @@ graph TD; **But:** Transformer l'arbre en tas. -* On continue à l'indice $N/2-1 = 4$: `12`. +* On continue à l'indice $N/2-2 = 3$: `12`. * Déjà un tas, rien à faire. ```{.mermaid format=pdf width=400 loc=figs/} @@ -560,7 +560,7 @@ graph TD; **But:** Transformer l'arbre en tas. -* On continue à l'indice $N/2-2 = 3$: `5`. +* On continue à l'indice $N/2-3 = 2$: `5`. * `5 < 8`, échanger `8` et `5` (aka `max(2, 5, 8)`) ```{.mermaid format=pdf width=400 loc=figs/} @@ -600,7 +600,7 @@ graph TD; **But:** Transformer l'arbre en tas. -* Indice $N/2-1 = 4$: `12`. +* Indice $N/2-2 = 3$: `12`. * Déjà un tas, rien à faire. ```{.mermaid format=pdf width=400 loc=figs/} @@ -624,7 +624,7 @@ graph TD; **But:** Transformer l'arbre en tas. -* Indice $N/2-2 = 3$: `5`. +* Indice $N/2-3 = 2$: `5`. * `5 < 8`, `5 <=> max(2, 5, 8)` ```{.mermaid format=pdf width=400 loc=figs/} @@ -663,7 +663,7 @@ graph TD; **But:** Transformer l'arbre en tas. -* Indice $N/2-3 = 1$: `16`. +* Indice $N/2-4 = 1$: `16`. * Déjà un tas, rien à faire. ```{.mermaid format=pdf width=400 loc=figs/} @@ -687,7 +687,7 @@ graph TD; **But:** Transformer l'arbre en tas. -* Indice $N/2-4 = 1$: `1`. +* Indice $N/2-5 = 0$: `1`. * `1 < 16 && 1 < 8`, `1 <=> max(1, 16, 8)` ```{.mermaid format=pdf width=400 loc=figs/} @@ -1237,7 +1237,7 @@ rien tamisage(tab, i) ind_max = i si tab[ind_max] < tab[g] && size(tab) > g ind_max = g - si tab[ind_mx] < tab[d] && size(tab) > d + si tab[ind_max] < tab[d] && size(tab) > d ind_max = d retourne ind_max