ALGORITHM VISUALIZER

// bubble sort algorithm - the classic simple sorting method
export function bubbleSort(array: number[]): SortingStep[] {
    const steps: SortingStep[] = [];
    const arr = [...array]; // making a copy to avoid mutating original array
    
    const n = arr.length;
    
    // outer loop to number of passes - each pass puts the largest element in place
    for (let i = 0; i < n - 1; i++) {
        // inner loop to compare adjacent elements - bubble up the largest value
...