Looking for * Contrôles Continus - P2 - Promo 2029 test answers and solutions? Browse our comprehensive collection of verified answers for * Contrôles Continus - P2 - Promo 2029 at moodle.myefrei.fr.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Soient les fonctions suivantes :
void fonction1(t_cell *ptr_c){ printf("%d ", ptr_c->value); fonction1(ptr_c->next);}
void fonction2(t_list mylist){ fonction1(mylist.head);}
Quelle est l'affichage obtenu si on appelle la fonction2 sur la liste suivante ?
Soient les fonctions suivantes :
void fonction1(t_cell *ptr_c){ printf("%d ", ptr_c->value); fonction1(ptr_c->next);}
void fonction2(t_list mylist){ fonction1(mylist.head);}
Quelle est l'affichage obtenu si on appelle la fonction2 sur la liste suivante ?
Soient les fonctions suivantes :
void fonction1(t_cell *ptr_c){ printf("%d ", ptr_c->value); fonction1(ptr_c->next);}
void fonction2(t_list mylist){ fonction1(mylist.head);}
Quelle est l'affichage obtenu si on appelle la fonction2 sur la liste suivante ?
Let be the following functions :
void fonction1(t_cell *ptr_c){ printf("%d ", ptr_c->value); fonction1(ptr_c->next);}
void fonction2(t_list mylist){ fonction1(mylist.head);}
What is the display obtained if we call the function2 on the following list ?
Consider the following function, which recursively searches for the maximum in a list :
int maxRecList(t_cell *cell, int cur_max){ if (cell == NULL) { return cur_max; } if (cell->value > cur_max) { cur_max = cell->value; } return maxRecList(cell->next, cur_max);}we want to call this function from the main program, for a non-empty list named list_1.Which main program is used to make this call to obtain the correct result ?(we assume that all the right #includes have been made)
Let be the following functions :
void fonction1(t_cell *ptr_c){ printf("%d ", ptr_c->value); fonction1(ptr_c->next);}
void fonction2(t_list mylist){ fonction1(mylist.head);}
What is the display obtained if we call the function2 on the following list ?
On souhaite 'détruire' une liste, c'est à dire libérer (free()) toutes les cellules qui la constituent
on vous propose la fonction suivante :
void destroyList(t_list *ptr_list){ t_cell *cur; t_cell *prev; while (ptr_list->head !=NULL) { cur = ptr_list->head; prev = cur; while (cur->next != NULL) { prev = cur; cur = cur->next; } prev->next = NULL;
free(cur); }
}
Que pouvez-vous dire de cette fonction ? (plusieurs réponses)
We want to 'destroy' a list, i.e. free() all the cells in it.
we propose the following function :
void destroyList(t_list *ptr_list){ t_cell *cur; t_cell *prev; while (ptr_list->head !=NULL) { cur = ptr_list->head; prev = cur; while (cur->next != NULL) { prev = cur; cur = cur->next; } prev->next = NULL;
free(cur); }
}
What can you say about this function? (several answers)
the following function performs a chain at the head of the list (adds a new cell to the head) :
(we assume that the function t_cell *createCell(int); creates a new individual cell)
void addHead(t_list *p_list, int val){ t_cell *new = createCell(val); p_list->head = new; new->next = p_list->head;
}la fonction suivante effectue bien un chaînage en tête de liste (ajoute une nouvelle cellule en tête) :
(on suppose que la fonction t_cell *createCell(int); crée bien une nouvelle cellule individuelle)
void addHead(t_list *p_list, int val){ t_cell *new = createCell(val); p_list->head = new; new->next = p_list->head;
}