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
gaspard.legouic
cours
Commits
2815c418
Verified
Commit
2815c418
authored
2 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
some minor corrections
parent
c58817fb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides/cours_16.md
+38
-33
38 additions, 33 deletions
slides/cours_16.md
with
38 additions
and
33 deletions
slides/cours_16.md
+
38
−
33
View file @
2815c418
...
...
@@ -13,13 +13,13 @@ date: "2023-03-17"
#
Pseudocode d
'insertion (1/
2
)
#
L
'insertion (1/
4
)
*
Deux parties:
*
Recherche le parent où se passe l'insertion.
*
Ajout du fils dans l'arbre.
## Recherche du parent
## Recherche du parent
(pseudo-code)
```
arbre position(arbre, clé)
...
...
@@ -38,16 +38,38 @@ arbre position(arbre, clé)
retourne arbre
```
# Pseudo-code d'insertion (2/2)
# L'insertion (2/4)
## Recherche du parent (code)
. . .
```
C
tree_t position(tree_t tree, key_t key) {
tree_t curr = tree;
if (NULL != curr) {
tree_t subtree =
key > curr->key ? curr->right : curr->left;
while (key != curr->key && NULL != subtree) {
curr = subtree;
subtree = key > curr->key ? curr->right :
curr->left;
}
}
return curr;
}
```
# L'insertion (3/4)
*
Deux parties:
*
Recherche de la position.
*
Ajout dans l'arbre.
## Ajout du fils
## Ajout du fils
(pseudo-code)
```
ajout(arbre, clé)
rien
ajout(arbre, clé)
si est_vide(arbre)
arbre = nœud(clé)
sinon
...
...
@@ -60,31 +82,11 @@ ajout(arbre, clé)
retourne
```
# Code d'insertion en C (1/2)
## Recherche du parent (ensemble)
. . .
```
C
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;
}
}
return current;
}
```
# Code d'insertion en C (2/2)
# L'insertion (4/4)
## Ajout du fils (
ensembl
e)
## Ajout du fils (
cod
e)
\s
criptsize
...
...
@@ -115,7 +117,7 @@ tree_t add_key(tree_t *tree, key_t key) {
}
```
# La version PK (1/
N
)
# La version PK (1/
5
)
```
C
typedef struct _node {
...
...
@@ -135,7 +137,7 @@ void parcours_infixe(tree arbre, int n){
}
```
# La version PK (2/
N
)
# La version PK (2/
5
)
```
C
tree recherche(int cle, tree arbre){
...
...
@@ -152,7 +154,7 @@ tree recherche(int cle, tree arbre){
```
# La version PK (3/
N
)
# La version PK (3/
5
)
\f
ootnotesize
...
...
@@ -179,7 +181,7 @@ node* parent_insertion(int donnee, tree arbre){
```
# La version PK (4/
N
)
# La version PK (4/
5
)
\f
ootnotesize
...
...
@@ -206,7 +208,7 @@ tree insertion(int donnee, tree arbre){
}
```
# La version PK (5/
N
)
# La version PK (5/
5
)
```
C
int main(){
...
...
@@ -219,7 +221,7 @@ int main(){
arbre = insertion(5, arbre);
parcours_infixe(arbre, 0);
}
s
}
```
# La suppression de clé
...
...
@@ -300,6 +302,9 @@ flowchart TB;
:::: column
*
Si on enlève 10 il se passe quoi?
. . .
*
On peut pas juste enlever
`10`
et recoller...
*
Proposez une solution bon sang!
...
...
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