Skip to content
Snippets Groups Projects
Commit 5aeca225 authored by Pierre Kunzli's avatar Pierre Kunzli
Browse files

ca devrait etre bon

parent 53b9a6e4
No related branches found
No related tags found
4 merge requests!6Pk,!5Pk,!4correction recherche parent et ajout sauts slides,!3Re re correction recherche
Pipeline #15725 passed
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
...@@ -877,18 +877,18 @@ int arbre_size(tree_t tree) { ...@@ -877,18 +877,18 @@ int arbre_size(tree_t tree) {
``` ```
arbre position(arbre, clé) arbre position(arbre, clé)
si est_non_vide(arbre) si est_non_vide(arbre)
tant que clé(arbre) != clé && est_non_vide(suivant)
si clé < clé(arbre) si clé < clé(arbre)
suivant = gauche(arbre) suivant = gauche(arbre)
sinon sinon
suivant = droite(arbre) suivant = droite(arbre)
tant que clé(arbre) != clé && est_non_vide(suivant)
arbre = suivant arbre = suivant
si clé < clé(arbre) si clé < clé(arbre)
suivant = gauche(arbre) suivant = gauche(arbre)
sinon sinon
suivant = droite(arbre) suivant = droite(arbre)
returne arbre retourne arbre
``` ```
# Pseudocode d'insertion (2/2) # Pseudocode d'insertion (2/2)
...@@ -922,9 +922,9 @@ ajout(arbre, clé) ...@@ -922,9 +922,9 @@ ajout(arbre, clé)
tree_t position(tree_t tree, key_t key) { tree_t position(tree_t tree, key_t key) {
tree_t current = tree; tree_t current = tree;
if (NULL != current) { if (NULL != current) {
while (key != current->key && NULL != subtree) { tree_t subtree = key > current->key ? current->right :
subtree = key > current->key ? current->right :
current->left; current->left;
while (key != current->key && NULL != subtree) {
current = subtree; current = subtree;
subtree = key > current->key ? current->right : subtree = key > current->key ? current->right :
current->left; current->left;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment