Skip to content
Snippets Groups Projects
Commit 53ad04f9 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

Merge branch 'pk' into 'master'

Re re correction recherche

See merge request !3
parents 3e4713b8 360be3c5
No related branches found
No related tags found
1 merge request!3Re re correction recherche
Pipeline #15738 passed
......@@ -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