-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharbre.c
More file actions
65 lines (49 loc) · 998 Bytes
/
arbre.c
File metadata and controls
65 lines (49 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "arbre.h"
/* -------------------------------------------------------*/
/* Primitives de gestion des arbres */
/* -------------------------------------------------------*/
TArbre arbreConsVide()
{
return NULL;
}
int arbreEstVide(TArbre a)
{
return (a==NULL);
}
TArbre arbreCons(char c, int n, TArbre fg, TArbre fd)
{
TArbre a = (TArbre)malloc(sizeof(struct Noeud));
a->lettre = c;
a->nboccurrence = n;
a->fgauche = fg;
a->fdroite = fd;
return a;
}
char arbreRacineLettre(TArbre a)
{
return a->lettre;
}
int arbreRacineNbOcc(TArbre a)
{
return a->nboccurrence;
}
TArbre arbreFilsDroit(TArbre a)
{
return a->fdroite;
}
TArbre arbreFilsGauche(TArbre a)
{
return a->fgauche;
}
void arbreSuppr(TArbre a)
{
if (arbreEstVide(a)==1)
{
arbreSuppr(a->fgauche);
arbreSuppr(a->fdroite);
free(a);
}
}