Saad Dahlab University - Blida1 Module : Algorithmic 2
Faculty des Sciences March 2024
Computer Science Departement 1st Test
1st Engineer Duration : 30 mn
EXERCIS
EXERCISE 1 (2
(2 POINTS).
POINTS) Let P be a pointer and A be an array of integers (int).
1. Create array A in two different ways:
Static
Dynamic
2. Write the necessary instructions (declaration + assignment) allowing the pointer P to contain the
address 100C, which represents the address of an element (a cell) of A.
Declaration
Instructions
3. How can we increase the size of the array by 10 cells? Give two different ways.
Static
Dynamic
EXERCI
EXERCIS
CISE 2 (3
(3 POINTS).
POINTS)
Given the polynomial 2 3 0.5 1 which is represented by the following Linked
List “LL” (sorted in descending order of exponent where each node contains an exponent and the
corresponding (non-zero) coefficient):
Using the LL model, write the following functions:
1. ProdScal(a, P) which returns a new LL representing the scalar product of the polynomial by an integer
"a", e.g: 5, 5∗ 10 15 2.5 5.
2. Sum(P1, P2) which returns a new LL representing the sum of the two polynomials P1 and P2.
3. Diff(P1, P2) which returns a new LL representing the difference between the two polynomials P1 and
P2. For example: 1 10 15 2.5 15 ; 2 7 5 2.5 15
1, 2 1 1 7 10 10 30
!! 1, 2 1 1 7 10 20 5
1/1
Université Saad Dahlab de Blida 1 Module : Algorithmique 2
Faculté des Sciences Mars 2024
Département d’Informatique Interrogation 1
1ère Ingénieur Durée : 30 mn
EXERCICE 1 (2
(2 POINTS).
POINTS) Soit P un pointeur et A un tableau d’entier (int)
4. Créer le tableau A de deux manières différentes
Statique
Dynamique
5. Ecrire les instructions nécessaires (déclaration + affectation) permettant au pointeur P de contenir
l’adresse 100C qui représente l’adresse d’un élément (une case) de A.
Déclaration
Instructions
6. Comment peut-on augmenter la taille du tableau de 10 cases ? Donner deux méthodes différentes.
Statique
Dynamique
EXERCICE
EXERCICE 2 (3
(3 POINTS).
POINTS)
Soit le polynôme 2 3 0.5 1 qui est représenté par une liste chaînée (LL) suivante
(triée dans l’ordre décroissant des exposants où chaque maillon contient un exposant et le coefficient (non
nul) correspondant):
En utilisant le modèle de LL, écrire les fonctions suivantes :
1. ProdScal (a, P) qui retourne une nouvelle LL représentant le produit scalaire du polynôme par un
entier « a », e.g : 5, 5∗ 10 15 2.5 5.
2. Sum (P1, P2) qui retourne une nouvelle LL représentant la somme des deux polynômes P1 et P2.
3. Diff (P1, P2) qui retourne une nouvelle LL représentant la différence entre les deux polynômes P1 et
P2. Par exemple : 1 10 15 2.5 15 ; 2 7 5 2.5 15
1, 2 1 1 7 10 10 30
!! 1, 2 1 1 7 10 20 5
1/1