B2.4 · Algorithm efficiency · Covered

Big O notation

Review Big O notation with the class handout and textbook pages 358–361. Compare how time and auxiliary space grow with input size.

17 Sept 2026 · 55 minutes

For this lesson

Python · step by step

Linear growth · O(n)

Watch the number of marked operations as input size changes.

Select Play or Next line to follow Python execution.

Python implementation

The highlight marks the next line to execute. Values show the state before that line.

visits = []def growth_linear(n):    for i in range(n):        visits.append(i)    return len(visits)

visits is an instrumentation list used only to show work. Do not count this display logging when judging the underlying algorithm’s auxiliary space. We count append events, not every Python operation.

Python · step by step

Auxiliary space

Compare a running total with a growing copy of the input.

Select Play or Next line to follow Python execution.

Python implementation

The highlight marks the next line to execute. Values show the state before that line.

def auxiliary_space(items, copy_input):    total = 0    working = []    for value in items:        total = total + value        if copy_input:            working.append(value)    return total

The supplied list is input space. total and value occupy a fixed number of slots in our classroom model. The copy grows to n elements. Without the copy: O(1) auxiliary space; with it: O(n). Both scans take O(n) time.

By the end of this lesson

  • Distinguish input size from the number of operations.
  • Compare common growth patterns without relying on a particular computer’s speed.
  • Explain why constant factors do not change the Big O class.

Use these activities to review the topic at your own pace. Timings are approximate.

Review the lesson

01 · 5 minutes

Start with a comparison

Compare looking up the first list item with checking every item. What changes when the list doubles in length?

02 · 15 minutes

Count operations

Count the work in a single loop over n values, two consecutive loops, and two nested loops. Try n = 4 and n = 8 before generalizing.

03 · 15 minutes

Describe growth

Connect constant, logarithmic, linear and quadratic growth to the algorithms you have met. Distinguish growth rate from measured execution time.

04 · 15 minutes

Apply the notation

Compare linear search with binary search. State the case being considered and explain the role of sorted input. Discuss auxiliary space separately from time.

05 · 5 minutes

Explain

Explain why doing two full passes over a list still has linear growth rather than quadratic growth.

Before you leave

Exit question

If an input doubles, what happens to the work in a linear algorithm and a quadratic algorithm?

Homework for this topic

Due 18 Sept 2026 · 4 pages · Assigned

Read pages 358–361: Big O notation

Review the Big O lesson by reading pages 358–361 in Computer Science for the IB Diploma by Baumgarten, Ganea & Turland. Next: binary search.