Activity 01
Pair Coding: Complexity Prediction
Pairs write three functions: constant time array lookup, linear search, and nested loop sum. They input sizes from 10 to 1000, time executions using Python's time module, and plot results. Discuss which matches O(1), O(n), O(n²).
Explain the purpose of Big O notation in algorithm analysis.
Facilitation TipDuring Pair Coding, ask students to verbalise their thought process when predicting complexity, especially for nested loops, to make implicit reasoning explicit.
What to look forPresent students with three short code snippets: one with a single loop (O(n)), one with nested loops (O(n^2)), and one with a direct array access (O(1)). Ask them to write down the Big O complexity for each snippet and a one-sentence justification.