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
jacquesw.ndoumben
cours
Commits
ca3e2023
Verified
Commit
ca3e2023
authored
1 year ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
fixed tree_t -> node *
parent
21355279
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_17.md
+11
-12
11 additions, 12 deletions
slides/cours_17.md
with
11 additions
and
12 deletions
slides/cours_17.md
+
11
−
12
View file @
ca3e2023
...
...
@@ -39,7 +39,7 @@ parcours_postfixe(arbre a)
visiter
(
a
)
```
#
# Rappel: parcours (préfixe, RGD)
# Rappel: parcours (préfixe, RGD)
. . .
...
...
@@ -106,9 +106,8 @@ typedef struct _node {
struct _node* left;
struct _node* right;
} node;
typedef node* tree_t;
tree_t search(key_t key, tree_t tree) {
tree_t current = tree;
node * search(key_t key, node * tree) {
node * current = tree;
while (NULL != current) {
if (current->key > X) {
current = current->gauche;
...
...
@@ -127,7 +126,7 @@ tree_t search(key_t key, tree_t tree) {
Écrire le code de la fonction
```
C
int tree_size(
tree_t
tree);
int tree_size(
node *
tree);
```
qui retourne le nombre total de nœuds d'un arbre et poster le résultat sur
...
...
@@ -139,7 +138,7 @@ additionné au nombre de nœuds dans le sous-arbre de droite.
. . .
```
C
int arbre_size(
tree_t
tree) {
int arbre_size(
node *
tree) {
if (NULL == tree) {
return 0;
} else {
...
...
@@ -238,11 +237,11 @@ ajout(arbre, clé)
. . .
```
C
tree_t
position(
tree_t
tree, key_t key) {
tree_t
current = tree;
node *
position(
node *
tree, key_t key) {
node *
current = tree;
if (NULL != current) {
tree_t
subtree = key > current->key ? current->right :
current->left;
node *
subtree = key > current->key ? current->right :
current->left;
while (key != current->key && NULL != subtree) {
current = subtree;
subtree = key > current->key ? current->right :
...
...
@@ -289,13 +288,13 @@ rien ajout(arbre, clé)
. . .
```
C
tree_t
add_key(
tree_t
*tree, key_t key) {
node *
add_key(
node *
*tree, key_t key) {
node_t *new_node = calloc(1, sizeof(*new_node));
new_node->key = key;
if (NULL == *tree) {
*tree = new_node;
} else {
tree_t
subtree = position(*tree, key);
node *
subtree = position(*tree, key);
if (key == subtree->key) {
return NULL;
} else {
...
...
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