Skip to content
Snippets Groups Projects
Commit b4f397c3 authored by pierre.kunzli's avatar pierre.kunzli
Browse files

correction de l'algo de recherche de parent, mais mieux

parent 72d5729e
No related branches found
No related tags found
5 merge requests!6Pk,!5Pk,!4correction recherche parent et ajout sauts slides,!3Re re correction recherche,!2Nouvelle correction de l'algo de recherche
Pipeline #15712 passed
......@@ -877,16 +877,12 @@ int arbre_size(tree_t tree) {
```
arbre position(arbre, clé)
si est_non_vide(arbre)
si clé < clé(arbre)
suivant = gauche(arbre)
sinon
suivant = droite(arbre)
tant que clé(arbre) != clé && est_non_vide(suivant)
arbre = suivant
si clé < clé(arbre)
suivant = gauche(arbre)
sinon
suivant = droite(arbre)
arbre = suivant
returne arbre
```
......@@ -921,12 +917,10 @@ ajout(arbre, clé)
tree_t position(tree_t tree, key_t key) {
tree_t current = tree;
if (NULL != current) {
tree_t subtree = key > current->key ? current->right :
current->left;
while (key != current->key && NULL != subtree) {
current = subtree;
subtree = key > current->key ? current->right :
current->left;
current = subtree;
}
}
return current;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment