Skip to content
Snippets Groups Projects
Commit 6f75d181 authored by pierre.kunzli's avatar pierre.kunzli Committed by orestis.malaspin
Browse files

Nouvelle correction de l'algo de recherche

parent 1e82f60b
No related branches found
No related tags found
1 merge request!2Nouvelle correction de l'algo de recherche
......@@ -877,11 +877,11 @@ 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)
si clé < clé(arbre)
suivant = gauche(arbre)
sinon
suivant = droite(arbre)
arbre = suivant
returne arbre
```
......@@ -917,9 +917,9 @@ 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) {
subtree = key > current->key ? current->right :
current->left;
current = subtree;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment