IB Computer Science HL · Year 2 · Lesson 6

Flowchart Tracing and Algorithm Efficiency

Trace standard flowcharts and describe how time and space complexity affect algorithm scalability.

Paper 250 minutesB1.1.4 · B2.4.1
Today’s targets

What you need to be able to do

2 / 10
  • recognize the standard flowchart symbols and trace control flow;
  • track variables and determine output from a flowchart;
  • distinguish time complexity from space complexity;
  • describe common Big O growth patterns and what they mean for scalability;
  • choose between correct algorithms using efficiency and scalability requirements.
B1.1.4B2.4.1
Paper 2 habitRead the command term and the data given. A technically correct answer still needs to answer the exact task.
Learn + retrieve

Rapid Recall Deck

3 / 10

Attempt each card first. If a term is new, flip and study it, then answer it again without looking. Mark only secure recall as “Know it”.

B1.1.4 · Flowcharts

Recognize the standard symbols

4 / 10

Start / End

Terminal

Process / Operation

Rectangle

Input/Output

Parallelogram

Decision

Diamond

Flowline

Arrow showing the direction of control.

Connector

Links separated flowchart regions.

Trace

Follow control and variable changes

5 / 10
Start Input n total = 0 i = 1 i ≤ n? total = total + i i = i + 1 Output total End Yes No

Trace for n = 4

Track i and total each time the decision is reached.
State the final output.

At the decision: (1,0), (2,1), (3,3), (4,6), (5,10). When i = 5, 5 ≤ 4 is False, so the flowchart outputs 10.

B2.4.1 · Describe

Big O describes growth

6 / 10

Time complexity

How the amount of work or running time grows as input size n grows.

Space complexity

How the additional memory required by the algorithm grows as n grows.

O(1)

Approximately constant growth.

O(log n)

Growth slows because the remaining problem is repeatedly reduced.

O(n)

Work grows roughly in direct proportion to input size.

O(n²)

Work grows roughly with the square of input size.

FAQ boundaryFor B2.4.1, focus on describing the nature of the Big O calculation and what the growth means for scalability; formal algebraic derivation is not the goal.
Recognize scaling

Connect code structure to growth

7 / 10

Algorithm A

for value in data:
    print(value)

Algorithm B

for x in data:
    for y in data:
        print(x, y)

Describe the time complexity

A — one pass over n items.
B — for each of n items, process n items again.
Do not just name the notation — describe what happens when n grows.

A: O(n) time because the loop performs work once for each input item, so doubling n roughly doubles the iterations. B: O(n²) time because the nested loops produce roughly n × n pairs, so doubling n can produce about four times as many iterations.

Scalability

Choose an algorithm for the data size

8 / 10
ScenarioTwo correct algorithms solve the same task. Algorithm X uses O(n) time and O(1) extra space. Algorithm Y uses O(n²) time and O(1) extra space.

Describe the choice

The input may grow from 100 records to 1,000,000 records. Which algorithm is more scalable, and why?

Time — compare how the two running times grow as n becomes large.
Extra space — compare the additional memory used by the two algorithms in this scenario.
Recommendation — choose the more scalable option and link it to the data-size increase.

Algorithm X is more scalable for very large inputs because its time grows linearly with n, whereas Algorithm Y's time grows quadratically. The difference becomes much larger as n increases. Both have O(1) extra space here, so the main deciding factor is the time-growth requirement.

Exam lens

Teacher-created Paper 2 practice

9 / 10

1. A flowchart uses a diamond containing count < 5?. Explain what the diamond controls.

2. An algorithm performs one constant-time check for each item in a List of length n. State and describe its time complexity.

3. Algorithm P uses O(log n) time and Algorithm Q uses O(n) time for the same search task. Describe why P may be preferable as n becomes very large.

  1. The decision evaluates the condition and directs control along one of the outgoing paths depending on whether the condition is True or False.
  2. O(n): the work grows roughly in direct proportion to the number of items because each item is checked once.
  3. O(log n) grows more slowly than O(n), so as n becomes very large the number of steps increases much less rapidly, assuming the requirements of the logarithmic algorithm are satisfied.
Homework

Finish the learning cycle

10 / 10

IA — main task

Review the IA algorithms or planned processing steps. Identify one operation that may be repeated as the amount of data grows and note whether scalability could matter.

Syllabus — short retrieval

Redo the flowchart trace for a different input such as n = 5, then explain aloud the difference between O(n) and O(n²) without using a memorized definition.