Skip to content
Computer Science · Grade 11

Active learning ideas

Sorting Algorithms: Selection and Bubble Sort

Active learning lets students experience sorting algorithms step by step, which builds intuition for abstract processes. By moving cards, tracing code, and racing outputs, students connect the algorithmic rules to the outcomes they produce, making these foundational concepts stick.

Ontario Curriculum ExpectationsCS.HS.A.3CS.HS.A.4
20–35 minPairs → Whole Class4 activities

Activity 01

Experiential Learning30 min · Pairs

Pair Programming: Implement Selection Sort

Pairs write pseudocode first, then code selection sort in Python or JavaScript. Test on arrays of 5-10 elements, printing array states after each pass. Discuss swaps observed.

Compare the efficiency of selection sort and bubble sort for small datasets.

Facilitation TipDuring Pair Programming: Implement Selection Sort, circulate and ask pairs to explain their swap conditions aloud to catch logic errors early.

What to look forProvide students with a small, unsorted array (e.g., [5, 1, 4, 2]). Ask them to manually perform one pass of bubble sort and write down the array's state after the pass, and identify how many swaps occurred.

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

Activity 02

Experiential Learning25 min · Small Groups

Small Groups: Bubble Sort Card Sort

Distribute shuffled number cards to groups of 4. Perform bubble sort passes aloud, swapping as needed and recording passes on chart paper. Compare to selection sort on same set.

Explain the mechanism by which bubble sort moves elements to their correct positions.

Facilitation TipIn Small Groups: Bubble Sort Card Sort, limit each pass to 30 seconds to force students to focus on the comparison-swap cycle.

What to look forPose the question: 'Imagine you have a list of 10 student scores to sort from highest to lowest. Which algorithm, selection sort or bubble sort, do you think would be more efficient, and why?' Guide students to discuss the number of comparisons and swaps.

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

Activity 03

Experiential Learning35 min · Whole Class

Whole Class: Efficiency Race

Project two implementations; input growing arrays and time runs live. Class votes on winner per size, plots results to graph time vs. n. Debrief patterns.

Critique the practical applicability of these basic sorting algorithms in real-world scenarios.

Facilitation TipDuring Efficiency Race, provide a stopwatch so students time their runs and record swaps to develop a habit of measuring performance.

What to look forOn an index card, ask students to write down the primary difference in how selection sort and bubble sort find and place elements in their correct positions.

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

Activity 04

Experiential Learning20 min · Individual

Individual: Trace and Visualize

Students trace bubble sort on paper for given array, drawing swaps. Use online visualizer to verify, note optimized early-stop version.

Compare the efficiency of selection sort and bubble sort for small datasets.

Facilitation TipDuring Trace and Visualize, require students to label each step with the algorithm’s invariant to reinforce correctness.

What to look forProvide students with a small, unsorted array (e.g., [5, 1, 4, 2]). Ask them to manually perform one pass of bubble sort and write down the array's state after the pass, and identify how many swaps occurred.

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

A few notes on teaching this unit

Teach these algorithms by starting with physical models before code. Students need to see why a swap happens, not just that it does. Avoid rushing to optimization; emphasize the cost of each comparison and swap. Research shows that tracing on paper first reduces errors when students later implement the same logic in code.

Students will confidently trace the steps of both algorithms on paper and in code, explain why each pass occurs, and discuss the efficiency trade-offs between them. They will also recognize that neither algorithm scales well, preparing them for more advanced sorts.


Watch Out for These Misconceptions

  • During Pair Programming: Implement Selection Sort, some students assume the algorithm always needs n passes regardless of data order.

    After the first implementation, ask pairs to test on a nearly-sorted list and compare pass counts to their initial assumption.

  • During Small Groups: Bubble Sort Card Sort, students believe bubble sort stops after a single pass if no swaps occur.

    During the activity, have groups rerun the pass until no swaps happen, then count the total passes to correct this idea.

  • During Efficiency Race, students think selection sort is always slower because it does more swaps.

    During the race, display real-time swap and comparison counts so students see selection sort’s O(n) swaps versus bubble sort’s O(n²) swaps in worst case.


Methods used in this brief