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

Re re correction recherche

parent 3e4713b8
No related branches found
No related tags found
1 merge request!3Re re correction recherche
......@@ -790,7 +790,7 @@ typedef struct _node {
typedef node* tree_t;
tree_t search(key_t key, tree_t tree) {
tree_t current = tree;
while (NULL != current && !success) {
while (NULL != current) {
if (current->key > X) {
current = current->gauche;
} else if (current->key < X){
......@@ -877,13 +877,18 @@ 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
retourne arbre
```
# Pseudocode d'insertion (2/2)
......@@ -917,10 +922,12 @@ 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