Esempio n. 1
0
def constructionArbre(l):
    A = Arbre()
    if len(l) == 0:
        showinfo("Erreur", "Le fichier est vide")
        return A
    elif len(l) == 1:
        A = Feuille(l[0])
        return A
    A.gauche = Feuille(l[0])
    A.droit = Feuille(l[1])

    for i in range(2, len(l)):
        A = A.constructionArbre(l[i])
    A.equilibre()

    return A
Esempio n. 2
0
def constructionArbreLong(l):
    A = Arbre()
    if len(l) == 1:
        A = Feuille(l[0])
        return A
    else:
        A.droit = Feuille(l[0])
        A.gauche = Feuille(l[1])

    for i in range(2, len(l)):
        tmp = Arbre()
        tmp.gauche = Feuille(l[i])
        tmp.droit = A
        A = tmp
    A.equilibre()

    return A
Esempio n. 3
0
def constructionMobile(l):
    A = Arbre()
    if type(l[0]) is int:
        A.gauche = Feuille(l[0])
    elif type(l[0]) is list:
        A.gauche = constructionMobile(l[0])

    if len(l) <= 1:
        return A.gauche

    if type(l[1]) is int:
        A.droit = Feuille(l[1])
    elif type(l[1]) is list:
        A.droit = constructionMobile(l[1])
    A.equilibre()

    return A