← Retour au cours : Algorithmes et Structures de Données
⚠️ Mode Visiteur : Vous lisez ce cours gratuitement. Créez un compte pour sauvegarder votre progression et obtenir des badges ! 🏆

Algorithmes de tri

Bubble Sort et Quick Sort

Bubble Sort O(n²)

function bubbleSort(arr) {
    for(let i=0; i<arr.length; i++) {
        for(let j=0; j<arr.length-1; j++) {
            if(arr[j] > arr[j+1]) {
                [arr[j], arr[j+1]] = [arr[j+1], arr[j]];
            }
        }
    }
    return arr;
}

📝 Vous avez terminé cette leçon ?

Créez un compte gratuit pour sauvegarder votre progression !

Créer un compte gratuit