Files
1ereNSI/algorithmes/mini-projets/README.md

2.0 KiB

Mini-projets — Algorithmes de tri et recherche dichotomique

Séance de révision avant DS (mardi). Chaque groupe reçoit un projet différent. Durée : 1h à 1h30. Langage : Python (sauf projet 09 : Python + HTML/CSS).

Règle commune : vous devez implémenter vous-mêmes tri_insertion, tri_selection et dichotomique. Interdiction d'utiliser sort() ou sorted().


Répartition des groupes

# Projet Algorithmes utilisés Difficulté
01 Le Nombre Mystère Dichotomie Facile
02 Le Tri de Cartes Tri insertion Facile
03 Le Podium Tri sélection + Dichotomie Facile
04 L'Annuaire Tri insertion + Dichotomie Moyen
05 Le Correcteur Tri insertion + Dichotomie (voisins) Moyen
06 La Bibliothèque Tri sélection + Dichotomie Moyen
07 La Météo Tri insertion + Dichotomie Moyen
08 La Course des Algos Tri insertion vs Tri sélection Difficile
09 Le Générateur Web Tri insertion + Dichotomie → HTML Difficile

Rappels des algorithmes

def tri_insertion(tab):
    for i in range(1, len(tab)):
        x = tab[i]
        j = i
        while j > 0 and tab[j - 1] > x:
            tab[j] = tab[j - 1]
            j -= 1
        tab[j] = x
    return tab

def tri_selection(tab):
    n = len(tab)
    for i in range(n):
        mini = i
        for j in range(i + 1, n):
            if tab[j] < tab[mini]:
                mini = j
        tab[i], tab[mini] = tab[mini], tab[i]
    return tab

def dichotomique(tab, x):
    a = 0
    b = len(tab) - 1
    while a <= b:
        m = (a + b) // 2
        if tab[m] == x:
            return True
        elif tab[m] < x:
            a = m + 1
        else:
            b = m - 1
    return False

Auteur : Florian Mathieu — Licence CC BY NC