Maggie HTTN
Case Study • Foundational Algorithms

Bubble Sort

A structured learning module for adjacent comparison, swap reasoning, and pass-by-pass sorting.

Bubble Sort is often one of the first sorting algorithms learners encounter, but students still confuse what each pass is doing, why only adjacent values are compared, and how the largest unsorted value moves toward the end. This module makes each comparison and swap visible so learners can follow how repeated local decisions gradually produce global order.

The lesson focuses on the mental model learners need most: compare neighboring values, swap when they are out of order, and repeat passes until the array is sorted.

Project Scope

Curricular Target
Introductory programming, Data Structures, and foundational algorithm courses.
Delivery Model
Hybrid instructional module; adaptable for lecture, guided practice, or self-study.
Learner Profile
Beginners learning comparison-based sorting and building early intuition about pass-based algorithms.
Primary Objective
Enable learners to explain how repeated adjacent comparisons and swaps move larger values toward their final positions.

Core Learning Outcomes

  • Explain how Bubble Sort uses adjacent comparisons to gradually order an array.
  • Trace the compare-and-swap cycle across multiple passes.
  • Identify which value “bubbles” to the end of the unsorted region after each pass.
  • Compare Bubble Sort with Selection Sort and Insertion Sort in terms of swaps, comparisons, and efficiency.

Learning Challenge

Learners often understand that Bubble Sort compares neighboring values, but still struggle to track what each pass accomplishes. A common misunderstanding is assuming the entire array becomes sorted after one pass, rather than recognizing that each pass only guarantees the largest remaining unsorted value moves into place.

Design Strategy

Adjacent Comparison Made Explicit
Each comparison is shown between neighboring values so learners can focus on the local decision before thinking about the larger pattern.
Pass Structure Made Visible
The lesson emphasizes that one full pass moves the largest unsorted value to its final place, helping learners recognize progress across the array.
Swap as Conditional Action
Swaps occur only when two adjacent values are out of order, helping learners distinguish comparison from movement.
Repetition for Pattern Recognition
Repeated passes reinforce the same compare–swap pattern, making Bubble Sort easy to trace and compare with other beginner sorting methods.

Core Conceptual Model

Bubble Sort repeatedly compares adjacent values. If a pair is out of order, the values swap. After one full pass, the largest value in the unsorted region has moved to the end. Repeating this process gradually sorts the full array.

Algorithm Process

  1. Start at the beginning of the unsorted region.
  2. Compare adjacent values.
  3. Swap if the left value is greater than the right value.
  4. Continue to the end of the current pass.
  5. Repeat until no swaps are needed or the array is fully sorted.

Performance & Properties

  • Worst Case: O(n²)
  • Best Case: O(n) with an early-stop optimization when the array is already sorted
  • Space: O(1), in-place
  • Stable: Yes
  • Learning Value: Strong for building intuition about local comparisons and repeated passes.

Common Learner Misconceptions

  • Thinking one pass sorts the entire array.
  • Confusing Bubble Sort with Selection Sort’s minimum-selection pattern.
  • Swapping values that are already in correct order.
  • Forgetting that the unsorted region becomes smaller after each full pass.

Solution Design

The learning sequence is structured to make each pass of Bubble Sort visible as a repeated compare-and-swap pattern rather than as a hidden loop.

1. Whole Array Before Passes

The lesson begins with the full unsorted array so learners can see that every pass works across the current unsorted region.

2. Compare Before Swap

Each adjacent comparison is shown before any movement occurs, helping learners distinguish the decision phase from the action phase.

3. Largest Value Moves Rightward

The pass is framed around what rises to the end of the unsorted region, reinforcing what one full traversal actually accomplishes.

4. Pass Boundaries as Progress Markers

The lesson marks the completed right side so learners can see that later passes do not need to revisit values already in final position.

5. Repetition for Pattern Stabilization

Repeated passes help learners recognize that Bubble Sort depends on the same small local rule applied many times.


Design Refinement:

Early confusion often centered on whether a swap should happen at every comparison and whether one pass was enough to sort the array.

To address this, the compare and swap actions were visually separated, and each pass ended with explicit emphasis on which value had reached its final position.

Interactive Implementation

The animation highlights adjacent comparisons and conditional swaps so learners can follow Bubble Sort as a pass-based process.

Watch actively: pause, predict whether the next pair will swap, and decide which value will settle at the end of the pass.

This implementation shows how repeated adjacent comparisons and swaps gradually move larger values to the right until the array becomes sorted.

Guided Worksheet (Pause & Predict)

These worksheet prompts are designed to support active learning during the animation. Pause the video at each pass, predict what will happen next, then continue to confirm or revise your reasoning.

Part 1 — Reading the Current Pair
  • Which two adjacent values are being compared right now?
  • Are they already in the correct order?
  • Should a swap happen, or should the algorithm move on?
Part 2 — Predict the End of the Pass
  • Which value do you think will bubble to the end of the current unsorted region?
  • Why is that value likely to end there after repeated comparisons?
  • What part of the array will no longer need attention after this pass?
Part 3 — After the Pass
  • Which value reached its final sorted position?
  • How did the unsorted region change before the next pass begins?
  • What pattern will repeat in the next pass?

Focus on the repeated cycle: compare neighbors, swap only if needed, and finish the pass knowing one more value is in its final place.

Assessment Strategy

This module evaluates understanding through guided prediction, pass-by-pass tracing, and comparison of sorting behavior.

  • Formative assessment (during learning): Students predict the next swap and explain why a pair should or should not change order.
    • Which pair is being compared right now?
    • Should the values swap, and why?
    • What does this comparison contribute to the current pass?
  • Application assessment (state + process): Students explain how each pass changes the array and shrinks the unsorted region.
    • Which value reached its final position after this pass?
    • What part of the array is now effectively sorted?
    • What will the next pass need to do?
  • Summative assessment (after learning): A short exit check confirms whether students can explain both the logic and the limitations of Bubble Sort.
    • How does Bubble Sort use adjacent comparisons to sort an array?
    • Why does one pass not completely sort the array?
    • How is Bubble Sort different from Selection Sort and Insertion Sort?

Assessment Activities

  • Prediction prompts before each adjacent comparison.
  • Pass-tracing questions showing how one value reaches the end.
  • Sorted-region checks after each completed pass.
  • Comparison questions contrasting Bubble Sort with other beginner sorting methods.

Inclusive Design

  • Explicit adjacent-pair cues reduce cognitive search during comparisons.
  • Separation of comparison and swap supports learners who need a slower reasoning tempo.
  • Pacing control supports repeated review of each pass.
  • Guided worksheet prompts support different learning preferences.

Instructional Impact

The module helps learners move from memorizing Bubble Sort as a repetitive list of swaps to understanding it as a structured pass-based process built on adjacent comparison, conditional movement, and gradual reduction of the unsorted region.