Enseignement de l'informatique et du numérique au lycée Boissy d'Anglas
https://icn-isn-boissy.yj.fr/wp/2022/10/14/corrige-exercice-3-les-arbres/
Export date: Thu May 16 4:15:21 2024 / +0000 GMT

Corrigé exercice 3 les arbres


Q1a
Nombre de nœuds = 7 (taille max pour une hauteur h : 2h - 1 = 1).
Q1b
profondeur maximale du nœud racine = 4
NB : par convention, ici un arbre réduit à un seul nœud est de hauteur 1
Q2
Taille : 7
Hauteur : 3 (par convention h(Δ) = 1)

Q3
Taille : 7
Hauteur : 4

Q4

def hauteur(self):
    return self.racine.hauteur()

Q5

def taille(self) -> int:
   if self.gauche == None and self.droite == None:
      return 1
   elif self.gauche == None:
      return 1 + self.droite.taille()
   elif self.droite == None:
      return 1 + self.gauche.taille()
   else:
      return 1 + self.gauche.taille() + self.droite.taille()
def taille(self):
   return self.racine.taille()

Q6a
2(h-1) – 1 < taille ≤ 2h – 1
doù t_min = 2(h-1) – 1

Q6b

def bien_construit(self) -> bool:
   return 2**(self.racine.hauteur() - 1) - 1 < self.racine.taille() <= 2**self.racine.hauteur() - 1
Post date: 2022-10-14 09:34:46
Post date GMT: 2022-10-14 07:34:46

Post modified date: 2022-10-14 09:38:07
Post modified date GMT: 2022-10-14 07:38:07

Export date: Thu May 16 4:15:21 2024 / +0000 GMT
This page was exported from Enseignement de l'informatique et du numérique au lycée Boissy d'Anglas [ https://icn-isn-boissy.yj.fr/wp ]
Export of Post and Page has been powered by [ Universal Post Manager ] plugin from www.ProfProjects.com