Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
Pierre-Alain FOUQUE
Input/Output and Recursive structures
2
Summary
1 - String and Files
2 - Recursive structure
3 - Example : chaining lists
String
• array containing char and terminating with the special character ‘\0’ of type char *t
• strlen gives the length of the string
• strcmp compares in the alphabetic order
• strncpy copies n characters
• cf. string.h
4
Files• File = pointer to a complex structur of type FILE
(FILE *)
• Opening a file in writing/reading mode
FILE *f = fopen(« toto.txt », «rw»);
Checking if everything works well
if(f==NULL) {
printf(« erreur dans fopen\n »);
exit(EXIT_FAILURE);
}
• Closing a file fclose(f);
Write and read in a file • fprintf(f, “Coucou %d\n”, a);
• int fputc(int c, FILE *f);
• int fputs(char *str, FILE *f)
• char c=fgetc(FILE *f);
• char *fgets(char * str, int size, FILE *f)
• read at most size-1 characters and strore them in str
• stop if there is a character‘\n’
• append \0’ at the end
6
StructuresStructures allow to put together objects of different
types
⇒ new type : struct bloc
6
StructuresStructures allow to put together objects of different
types
⇒ new type : struct bloc
struct bloc { int number; float value;};
6
StructuresStructures allow to put together objects of different
types
⇒ new type : struct bloc
struct bloc { int number; float value;};
Each object of this type has an integer field, called number
6
StructuresStructures allow to put together objects of different
types
⇒ new type : struct bloc
struct bloc { int number; float value;};
Each object of this type has an integer field, called number
• a floating field, called valeur
7
Pointers/Arrayint *pa;
⇒ declare a pointer pa onto an int
0x0A000x0B000x0C00 pa
7
Pointers/Arrayint *pa;
⇒ declare a pointer pa onto an int
pa = malloc(3*(sizeof(int));0x0A000x0B000x0C00 pa
7
Pointers/Arrayint *pa;
⇒ declare a pointer pa onto an int
pa = malloc(3*(sizeof(int));0x0A000x0B000x0C00 pa 0x0A01
7
Pointers/Arrayint *pa;
⇒ declare a pointer pa onto an int
pa = malloc(3*(sizeof(int));0x0A000x0B000x0C00 pa 0x0A01
The size can be modified by the program if it is not sufficient :
7
Pointers/Arrayint *pa;
⇒ declare a pointer pa onto an int
pa = malloc(3*(sizeof(int));0x0A000x0B000x0C00 pa 0x0A01
The size can be modified by the program if it is not sufficient :
realloc = malloc + copy
8
List
In algorithmic, the list is an important data structure:
8
List
In algorithmic, the list is an important data structure:
cell
2
8
List
In algorithmic, the list is an important data structure:
cell
2 5
8
List
In algorithmic, the list is an important data structure:
cell
2 5 3
8
List
In algorithmic, the list is an important data structure:
cell
Append a cell when needed
2 5 3
8
List
In algorithmic, the list is an important data structure:
cell
Append a cell when needed⇒ Dynamic structure
2 5 3
9
Structure cell
The cell has two fields :
• a value
• a new cell (or a pointer)
9
Structure cell
The cell has two fields :
• a value
• a new cell (or a pointer)
struct cellule {
9
Structure cell
The cell has two fields :
• a value
• a new cell (or a pointer)
struct cellule { int value;
9
Structure cell
The cell has two fields :
• a value
• a new cell (or a pointer)
struct cellule { int value; struct cellule next;
9
Structure cell
The cell has two fields :
• a value
• a new cell (or a pointer)
struct cellule { int value; struct cellule next;};
9
Structure cell
The cell has two fields :
• a value
• a new cell (or a pointer)
struct cellule { int value; struct cellule next;};
10
Recursive Structure
10
Recursive Structure
struct cellule { int value; struct cellule next;};
10
Recursive Structure
What is the size of this structure ?struct cellule { int value; struct cellule next;};
10
Recursive Structure
What is the size of this structure ?
t = 4 + t ⇒ infinite size ?
struct cellule { int value; struct cellule next;};
10
Recursive Structure
What is the size of this structure ?
t = 4 + t ⇒ infinite size ?
⇒ not recursive
struct cellule { int value; struct cellule next;};
10
Recursive Structure
What is the size of this structure ?
t = 4 + t ⇒ infinite size ?
⇒ not recursive
struct cellule { int value; struct cellule next;};
10
Recursive Structure
What is the size of this structure ?
t = 4 + t ⇒ infinite size ?
⇒ not recursive
struct cellule { int value; struct cellule next;};
struct cellule { int value; struct cellule *next;};
10
Recursive Structure
What is the size of this structure ?
t = 4 + t ⇒ infinite size ?
⇒ not recursive
struct cellule { int value; struct cellule next;};
Fixe size:an int and a pointer
struct cellule { int value; struct cellule *next;};
11
List
11
List
The list can be implemented as follows :
11
List
The list can be implemented as follows :
struct s_cellule { int value; struct s_cellule *next;};
11
List
The list can be implemented as follows :
struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
12
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
12
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
12
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
struct s_cellule
12
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
struct s_cellule
= cellule
12
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
struct s_cellule
= cellule
12
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
struct s_cellule
= cellulelist = pointer onto a
cellule
12
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;
struct s_cellule
= cellulelist = pointer onto a
cellule
Empty list = particular pointer ⇒ NULL
13
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;list nil = NULL;
13
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;list nil = NULL;
Type cellule
13
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;list nil = NULL;
Type cellule
Type list
13
List (suite)struct s_cellule { int value; struct s_cellule *next;};
typedef struct s_cellule cellule;typedef cellule *list;list nil = NULL;
Empty list = nilNULL = pointer 0
Type cellule
Type list
14
Size of structurestypedef struct { int number; float value;} sbloc;
sbloc *pb;pb = malloc(sizeof(sbloc));
14
Size of structurestypedef struct { int number; float value;} sbloc;
sbloc *pb;pb = malloc(sizeof(sbloc));
pb
14
Size of structurestypedef struct { int number; float value;} sbloc;
sbloc *pb;pb = malloc(sizeof(sbloc));
pb
1 2.0
14
Size of structurestypedef struct { int number; float value;} sbloc;
sbloc *pb;pb = malloc(sizeof(sbloc));
pb
1 2.0
sizeof(<type>)byte number for an object of type <type>
sizeof(sbloc)
15
Create a cell
list L; /* pointer onto a cell but no associate cell*/
L = malloc(sizeof(cellule)); /* memory is allocate
cell is not initialized */
15
Create a cell
list L; /* pointer onto a cell but no associate cell*/
L
?
L = malloc(sizeof(cellule)); /* memory is allocate
cell is not initialized */
15
Create a cell
list L; /* pointer onto a cell but no associate cell*/
L
L
?
L = malloc(sizeof(cellule)); /* memory is allocate
cell is not initialized */
15
Create a cell
*L is a cell :(*L).value : field value(*L).next : field next
list L; /* pointer onto a cell but no associate cell*/
L
L
?
L = malloc(sizeof(cellule)); /* memory is allocate
cell is not initialized */
16
Create a list
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
16
Create a list
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L…
16
Create a list
Let a list L
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L…
16
Create a list
Let a list LLet an integer x
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L…
16
Create a list
Let a list LLet an integer x
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
L…
16
Create a list
Let a list LLet an integer x
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
L…
16
Create a list
Let a list LLet an integer x
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
x
L…
16
Create a list
Let a list LLet an integer x
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
x
L…
16
Create a list
Let a list LLet an integer x
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
x
L1 new list
L…
17
Create a listlist cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
17
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
17
L1
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
17
L1L2
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
nil
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);
nil
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);
nil
3
L1
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);L2 = cons(6,L1);
nil
3
L1
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);L2 = cons(6,L1);
nil
3
L1
6
L2
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);L2 = cons(6,L1);
nil
3
L1
6
L2
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);L2 = cons(6,L1);L3 = cons(1,L2);
nil
3
L1
6
L2
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);L2 = cons(6,L1);L3 = cons(1,L2);
L3
1
nil
3
L1
6
L2
17
L1L2L3
Create a list
list L1,L2,L3;list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1 = cons(3,nil);L2 = cons(6,L1);L3 = cons(1,L2);
L3
1
nil
3
L1
6
L2
18
Interest of lists
18
Interest of lists
2 5 3
18
Interest of lists
• Append and delete are simple
2 5 3
18
Interest of lists
• Append and delete are simple
• create or destroy a cell
2 5 3
18
Interest of lists
• Append and delete are simple
• create or destroy a cell
• adapt the corresponding pointers (1 or 2)
2 5 3
18
Interest of lists
• Append and delete are simple
• create or destroy a cell
• adapt the corresponding pointers (1 or 2)
• Recursive Structure
2 5 3
18
Interest of lists
• Append and delete are simple
• create or destroy a cell
• adapt the corresponding pointers (1 or 2)
• Recursive Structure
⇒ The main functions are esay to implement thanks to the recursivity
2 5 3
19
Operations on liste
6 … L
19
Operations on listeAppend an element
6 … L
19
Operations on liste
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
Append an element
6 … L
19
Operations on liste
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
1
Append an element
6 … L
19
Operations on liste
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
1
Append an element Head and Tail
6 … L
19
Operations on liste
list cons(int x, list L) { list L1; L1 = malloc(sizeof(cellule)); L1->value = x; L1->next = L; return L1;}
L1
1
tail(L1)
Append an element Head and Tailint head(list L) { return L->value;}
list tail(list L) { return L->next}
head(L1)
6 … L
20
Recursive Functions : display
L2 5 3
20
Recursive Functions : display
Display a list can be described as follows:
L2 5 3
20
Recursive Functions : display
Display a list can be described as follows:print the head (as an integer)
L2 5 3
20
Recursive Functions : display
Display a list can be described as follows:print the head (as an integer)print the tail (as a list)
L2 5 3
20
Recursive Functions : display
Display a list can be described as follows:print the head (as an integer)print the tail (as a list)Rk : if the list is empty, do nothing
L2 5 3
20
Recursive Functions : display
void affiche_list(list L) { if (L != nil) { printf(“%d “,head(L)); affiche_list(tail(L));}}
Display a list can be described as follows:print the head (as an integer)print the tail (as a list)Rk : if the list is empty, do nothing
L2 5 3
20
Recursive Functions : display
void affiche_list(list L) { if (L != nil) { printf(“%d “,head(L)); affiche_list(tail(L));}}
Display a list can be described as follows:print the head (as an integer)print the tail (as a list)Rk : if the list is empty, do nothing
L2 5 3
stopping rules
21
Display (suite)
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3)
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2 print_list(→ 5 → 3)
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2 print_list(→ 5 → 3) L = → 5 → 3
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2 print_list(→ 5 → 3) L = → 5 → 3 print 5
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2 print_list(→ 5 → 3) L = → 5 → 3 print 5 print_list(→ 3)
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2 print_list(→ 5 → 3) L = → 5 → 3 print 5 print_list(→ 3) L = → 3
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2 print_list(→ 5 → 3) L = → 5 → 3 print 5 print_list(→ 3) L = → 3 print 3
L2 5 3
21
Display (suite)
void print_list(list L) { if (L != nil) { printf(“%d “,head(L)); print_list(tail(L)); }}
print_list(→ 2 → 5 → 3) L = → 2 → 5 → 3 print 2 print_list(→ 5 → 3) L = → 5 → 3 print 5 print_list(→ 3) L = → 3 print 3 print_list(nil)
L2 5 3
22
Recursive function: copy
L2 5 3
22
Recursive function: copy
To copy a list:
L2 5 3
22
Recursive function: copy
To copy a list:append the head to the copy of the tail
L2 5 3
22
Recursive function: copy
To copy a list:append the head to the copy of the tailRk : if the list is empty, return the empty list
L2 5 3
22
Recursive function: copy
list copie(list L) { list L1,L2; if (L == nil) return nil; L1 = copie(tail(L)); L2 = cons(head(L),L1); return L2;}
To copy a list:append the head to the copy of the tailRk : if the list is empty, return the empty list
L2 5 3
22
Recursive function: copy
list copie(list L) { list L1,L2; if (L == nil) return nil; L1 = copie(tail(L)); L2 = cons(head(L),L1); return L2;}
To copy a list:append the head to the copy of the tailRk : if the list is empty, return the empty list
L2 5 3
stopping rules
23
Copy (suite)
L5 3
23
Copy (suite)
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3)
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3)
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil)
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil) L = nil
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil) L = nil ⇒ nil
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil) L = nil ⇒ nil L1 = nil
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil) L = nil ⇒ nil L1 = nil ⇒ cons(3,nil) = → 3
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil) L = nil ⇒ nil L1 = nil ⇒ cons(3,nil) = → 3 L1 = → 3
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil) L = nil ⇒ nil L1 = nil ⇒ cons(3,nil) = → 3 L1 = → 3 ⇒ cons(5, → 3) = → 5 → 3
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
23
Copy (suite)
LL = copy(→ 5 → 3) L = → 5 → 3 L1 = copy(→ 3) L = → 3 L1 = copy(nil) L = nil ⇒ nil L1 = nil ⇒ cons(3,nil) = → 3 L1 = → 3 ⇒ cons(5, → 3) = → 5 → 3LL = → 5 → 3
L5 3
list copy(list L) { list L1; if (L == nil) return nil; L1 = copy(tail(L)); return cons(head(L),L1);}
24
Copy (suite)
L5 3
24
Copy (suite)
L5 3
list copie(list L) { list L1;
if (L == nil) return nil; L1 = copie(tail(L));
return cons(head(L),L1);}
24
Copy (suite)
L5 3
list copie(list L) { list L1;
if (L == nil) return nil; L1 = copie(tail(L));
return cons(head(L),L1);}
3
24
Copy (suite)
L5 3
list copie(list L) { list L1;
if (L == nil) return nil; L1 = copie(tail(L));
return cons(head(L),L1);}
LL5
3
24
Copy (suite)
L5 3
list copie(list L) { list L1;
if (L == nil) return nil; L1 = copie(tail(L));
return cons(head(L),L1);}
LL5
3
The modificationof a cell of LL
do not change the cases of L
25
Lists - end
So, the recursive structure of lists allows an easy implementation
• append an element
• copy, display, concatenation
• search an element
• delete an element
• …
26
Queue and stacks
Two types of list are important in algorithmics:
• list FIFO (First In, First Out) or Queue (file d’attente)
• list LIFO (Last In, First Out) or Stack (pile)
27
Conclusion
The dynamic structures have many advantages:
• récursives structures,very easy to manipulate recursive functions
• dynamic allocation of the memory, when needed (no loss of memory)