Skip to content
Computer Science · Grade 12

Active learning ideas

Sorting Algorithms: Simple

Students retain sorting algorithms best when they physically move data and see relationships between steps. Hands-on sorting with code and cards makes abstract comparisons concrete, helping students connect iteration counts to runtime behavior. These activities move beyond memorization to build lasting intuition about algorithm efficiency.

Ontario Curriculum ExpectationsCS.AA.7CS.P.17
20–45 minPairs → Whole Class4 activities

Activity 01

Stations Rotation30 min · Pairs

Pair Programming: Implement Bubble Sort

Pairs write Bubble Sort code for arrays of 10-20 elements. They add print statements to visualize swaps, run on random and sorted data, then discuss swap counts. Extend by modifying for early termination.

Compare the efficiency of Bubble Sort, Selection Sort, and Insertion Sort for small datasets.

Facilitation TipDuring Pair Programming: Bubble Sort, circulate and ask pairs to explain why swapping stops early on a nearly sorted array.

What to look forProvide students with a small array, e.g., [5, 1, 4, 2]. Ask them to trace the steps of Selection Sort, showing the array after each swap. Then, ask them to state the total number of swaps performed.

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 02

Stations Rotation25 min · Small Groups

Small Groups: Card Sort Race

Provide decks of 15 shuffled cards per group. Groups sort using Selection Sort rules: find min, swap to front. Time each round, rotate roles, compare to digital timers for same data.

Explain the step-by-step process of each simple sorting algorithm.

Facilitation TipFor Card Sort Race, provide a 10-card deck and a timer; challenge groups to complete the race twice with different initial orders.

What to look forDisplay a nearly sorted array (e.g., [1, 3, 2, 4, 5]) and ask students to predict which of the three simple sorting algorithms (Bubble, Selection, Insertion) would likely perform the fewest comparisons or swaps. Have them briefly justify their prediction.

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 03

Stations Rotation45 min · Whole Class

Whole Class: Efficiency Comparison

Project datasets of increasing sizes. Class votes predictions, runs all three algorithms coded by volunteers, charts runtimes. Discuss which wins for small, random, nearly sorted inputs.

Predict which simple sorting algorithm would perform best for a nearly sorted array.

Facilitation TipIn Efficiency Comparison, project a shared spreadsheet so students can log their pass counts and swap totals for direct comparison.

What to look forFacilitate a class discussion comparing the algorithms. Ask: 'If you had an array that was already sorted, which of these three algorithms would be the most efficient and why? Conversely, which would be the least efficient?'

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Stations Rotation20 min · Individual

Individual: Trace Insertion Sort

Students trace paper arrays step-by-step for worst, best cases. Code their version, test on 5 inputs, note shifts. Share one insight in class gallery walk.

Compare the efficiency of Bubble Sort, Selection Sort, and Insertion Sort for small datasets.

What to look forProvide students with a small array, e.g., [5, 1, 4, 2]. Ask them to trace the steps of Selection Sort, showing the array after each swap. Then, ask them to state the total number of swaps performed.

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills
Generate Complete Lesson

A few notes on teaching this unit

Teach these algorithms by having students first sort physically with cards before writing code, so they grasp the core logic. Avoid rushing to abstract O(n²) notation; instead, let students discover quadratic behavior through repeated trials. Emphasize that algorithm choice depends on data shape, not just size, to build flexible understanding.

By the end of these activities, students can implement Bubble, Selection, and Insertion Sort correctly, trace their steps on small arrays, and explain why one algorithm might run faster than another on the same data. They will use iteration counts and swap totals to justify their comparisons.


Watch Out for These Misconceptions

  • During Pair Programming: Bubble Sort, watch for students who assume Bubble Sort is always the slowest.

    Have pairs run Bubble Sort on a sorted array and count the zero swaps, then repeat with Selection and Insertion to see how each behaves on pre-sorted data.

  • During Efficiency Comparison, watch for students who claim all O(n²) sorts run identically.

    Use the live timer and swap counts to show that Insertion Sort often finishes faster on nearly sorted data, prompting students to revise their claim with evidence.

  • During Card Sort Race, watch for students who expect the same number of passes regardless of initial order.

    Ask groups to sort the same deck twice, once ascending and once descending, and compare pass counts to reveal how data order shapes performance.


Methods used in this brief