logo

Crowdly

Voici une fonction récursive qui calcule le plus grand élément d'un tableau entr...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Voici une fonction récursive qui calcule le plus grand élément d'un tableau entre les indices deb et fin (deb ≤ fin) :

fonction MaxTab (↓ T : TTableau, ↓ deb : entier, ↓ fin : entier) : entier

// ...

Variable 

milieu, M1, M2 : entier

Début

Si deb = fin alors

Afficher ("Coucou")

retourner T [deb]

Sinon

milieu ← (deb+fin) DIV 2

M1 ← MaxTab (T, deb, m)

M2 ← MaxTab (T, 1+m, fin)

si (M1 < M2) alors

retourner M2

Sinon

retourner M1

FSi

FSi

Fin

Si le tableau Tab = [7, 4, 5] est indicé à partir de 1

et si on appelle la fonction comme suit :

M ← MaxTab (Tab, 1, 3)

combien de fois le message "Coucou" s'affichera-t-il ?

More questions like this

Want instant access to all verified answers on arche.univ-lorraine.fr?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!