Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
algorithmique
cours
Commits
b4f397c3
Commit
b4f397c3
authored
3 years ago
by
pierre.kunzli
Browse files
Options
Downloads
Patches
Plain Diff
correction de l'algo de recherche de parent, mais mieux
parent
72d5729e
Branches
Branches containing commit
No related tags found
5 merge requests
!6
Pk
,
!5
Pk
,
!4
correction recherche parent et ajout sauts slides
,
!3
Re re correction recherche
,
!2
Nouvelle correction de l'algo de recherche
Pipeline
#15712
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides/cours_15.md
+2
-8
2 additions, 8 deletions
slides/cours_15.md
with
2 additions
and
8 deletions
slides/cours_15.md
+
2
−
8
View file @
b4f397c3
...
@@ -877,16 +877,12 @@ int arbre_size(tree_t tree) {
...
@@ -877,16 +877,12 @@ int arbre_size(tree_t tree) {
```
```
arbre position(arbre, clé)
arbre position(arbre, clé)
si est_non_vide(arbre)
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)
tant que clé(arbre) != clé && est_non_vide(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)
arbre = suivant
returne arbre
returne arbre
```
```
...
@@ -921,12 +917,10 @@ ajout(arbre, clé)
...
@@ -921,12 +917,10 @@ 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) {
tree_t subtree = key > current->key ? current->right :
current->left;
while (key != current->key && NULL != subtree) {
while (key != current->key && NULL != subtree) {
current = subtree;
subtree = key > current->key ? current->right :
subtree = key > current->key ? current->right :
current->left;
current->left;
current = subtree;
}
}
}
}
return current;
return current;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment