<?xml version="1.0" encoding="UTF-8"?>

<upm-export>
	<title>Enseignement de l&#039;informatique et du numérique au lycée Boissy d&#039;Anglas</title>
	<link>https://icn-isn-boissy.yj.fr/wp</link>
	<description></description>
	<pubDate>Wed May 6 11:55:52 2026 / +0000  GMT</pubDate>
	<generator>Universal Post Manager 1.1.2 [ www.ProfProjects.com ] </generator>
	<language></language>
	
			<item>
			<title>Corrigé exercice 2 les arbres</title>
			<link>https://icn-isn-boissy.yj.fr/wp/?p=3775</link>
			<pubDate>Wed May 6 11:55:52 2026 / +0000  GMT</pubDate>
			<guid isPermaLink="false">https://icn-isn-boissy.yj.fr/wp/?p=3775</guid>
			<content-encoded><![CDATA[<!-- wp:paragraph -->
<p><strong>1.a.</strong> Il y a 4 feuilles, d'étiquette 12, <code>val</code>, 21 et 32.<br><strong>1.b.</strong> Le sous-arbre gauche du nœud 23 est 19-21.<br><strong>1.c.</strong> La hauteur de l'arbre est 4. Sa taille est 9.<br><strong>1.d.</strong> Les valeurs possibles de <code>val</code> sont 16 et 17.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>2.a.</strong> Parcours infixe : 12-13-15-16-18-19-21-23-32<br><strong>2.b.</strong> Parcours suffixe : 12-13-16-15-21-19-32-23-18</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>3.a.</strong> </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3782,"sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image size-full"><a href="https://icn-isn-boissy.yj.fr/wp/wp-content/uploads/2022/10/image.png"><img src="https://icn-isn-boissy.yj.fr/wp/wp-content/uploads/2022/10/image.png" alt="" class="wp-image-3782"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><br><strong>3.b.</strong><br></p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre id="__code_24" class="wp-block-code"><code>racine = Noeud(18)
racine.insere(&#91;15, 13, 12, 16, 23, 32, 19, 21])
</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>(d'autres solutions sont possibles)</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>3.c.</strong> bloc 3 – bloc 2<br>ne rentre pas dans bloc 1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>4.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre id="__code_25" class="wp-block-code"><code>class Noeud():
    def __init__(self, v):
        self.ag = None
        self.ad = None
        self.v = v

    def insere(self, v):
        n = self
        est_insere = False
        while not est_insere:
            if v == n.v:
                est_insere = True
            elif v &lt; n.v:
                if n.ag != None:
                    n = n.ag
                else:
                    n.ag = Noeud(v)
                    est_insere = True
            else:
                if n.ad != None:
                    n = n.ad
                else:
                    n.ad = Noeud(v)
                    est_insere = True

    def insere_tout(self, vals):
        for v in vals:
            self.insere(v)

    def recherche(self, v):
        arbre = self
        while not arbre is None:
            if arbre.v == v:
                return True
            if v &lt; arbre.v:
                arbre = arbre.ag
            else:
                arbre = arbre.ad
        return False


    # version récursive (non demandée)

    def recherche_rec(self, v):
        if self is None:
            return False
        if self.v == v:
            return True
        if v &lt; self.v:
            if self.ag is not None:
                return self.ag.recherche_rec(v)
            else:
                return False
        else:
            if self.ad is not None:
                return self.ad.recherche_rec(v)
            else:
                return False


racine = Noeud(18)
racine.insere_tout(&#91;12, 13, 15, 14, 19, 21, 32, 23])
print(racine.recherche(149))
print(racine.recherche(12))</code></pre>
<!-- /wp:code -->]]></content-encoded>
			<excerpt-encoded><![CDATA[]]></excerpt-encoded>
			<wp-post_id>3775</wp-post_id>
			<wp-post_date>2022-10-14 08:46:31</wp-post_date>
			<wp-post_date_gmt>2022-10-14 06:46:31</wp-post_date_gmt>
				</item>
</upm-export>
