S5 Term 2 | ICT: Selection, Iteration and Trace Tables | Tutor Lesson Plan | 45-minute flow, teaching script, common errors, practice with answers
- 2026-12-05
Tutor lesson plan · S5 Term 2 ICT
Students can read the code but freeze when asked what total is on the third pass, and their while loops often forget to update the variable. This lesson lays the program out as a trace table so reading becomes counting.
01 Prior knowledge check (first 3 minutes)
If any of these is not secure, the trace table goes wrong from the first row. Repair it first:
| Skill | Quick check | Pass standard |
|---|---|---|
| Integer division | Halve 64 three times: what is left? | 8 |
| Assign and compare | How does x = x + 1 differ from x == x + 1? | The first assigns, the second compares |
| Adding a series | What is 1 plus 2 plus 3 plus 4 plus 5? | 15 |
02 Lesson flow (45 minutes)
| Time | Stage | Tutor does | Student does |
|---|---|---|---|
| 0-5 min | Diagnose | Show a five-line for loop and ask for total, take the answer only | Most say 5 or 10 and cannot trace it |
| 5-17 min | Trace table | Three columns i, total and test; n = 5 filled row by row, row six false | Students fill six rows and say why there is one extra |
| 17-30 min | for and while | for counts, while tests; halving 64 takes 6 steps | Students rewrite the same job as a while loop and check the exit condition |
| 30-38 min | Nesting and sort | 4 outer times 3 inner is 12; bubble sort on 8 items is 28 | Students compute six items and check the formula |
| 38-42 min | Search counts | Linear over 1,000 is 1,000; binary is 10, a factor of 100 | Students say why binary search needs sorted data |
| 42-45 min | Exit check | Collect three answers, note boundary, update or counting | Students answer without notes |
03 Teaching script (read it aloud)
Act one: a trace table is the program in slow motion
Students repeat: “Five passes, six rows, and the last test is false.”
Act two: for counts, while tests
Students repeat: “for counts, while tests, and the body must update the variable.”
Act three: nesting multiplies, search divides
Students repeat: “Nesting multiplies, binary divides, and sort before you bisect.”
04 Question types and steps
| Type | Example | Steps | Answer |
|---|---|---|---|
| Trace table | for i in range(1, 6) | Fill i, total and the test each pass, then one false row | 6 rows, total 15 |
| for to while | Halving 64 | Write the condition, update x and count in the body | 6 steps |
| Nested loop | 4 outer, 3 inner | Multiply the counts, do not add | 12 runs |
| Search counts | 1,000 items | Linear compares one by one; binary uses powers of two | binary 10 |
A flowchart and a trace table are two views of one program: the diamond chooses the path, the table records every value. With n = 5 the loop runs five times and the test six, the last one false.
05 Three independent practice questions
| Question | Answer | What to observe |
|---|---|---|
| How many times does for i in range(1, 7) run, and what is total at the end? | 6 times (1 to 6), total = 21 | Reading the upper bound as inclusive gives seven |
| x starts at 200; while x is greater than 1, halve it. How many divisions, and what is x at the end? | 7 divisions, ending at x = 1 | Missing the last step gives six |
| Outer range(5) with inner range(3): how many runs? And with inner range(4)? | 5 x 3 = 15; with range(4) it is 20, five more | Adding the two loops gives 8, the classic error |
06 Common errors and correction lines
| Error | Student usually writes | Tutor says |
|---|---|---|
| Trace table misses the last row | 5 passes written as 5 rows | There are 6 tests, and the last one is false. |
| while never updates | while x is greater than 1: total = total + 1 | The body needs x = x // 2 or the test never fails. |
| Nested counts added | 4 plus 3 is 7 runs | The inner loop runs in full each time, so 12. |
| Binary search on unsorted data | Run binary search on an unsorted list | Sort first, or the half you keep may not hold the target. |
07 Homework (paper and question numbers)
- S5 ICT practice paper Question 3 part 9: dictionary accumulation, print(acc) gives {2: 26, 1: 13}
- S5 ICT practice paper Question 3 part 11: why the default 0 in acc.get avoids a KeyError
- S5 ICT practice paper Question 4 part 13: bubble sort on six items is 6 times 5 over 2, so 15 comparisons
- S5 ICT practice paper Question 4 parts 14 and 15: binary search on 1,024 is 10 steps, linear is 1,024, a factor of 102.4
08 Exit check (last 3 minutes)
| Question | Answer | Verdict |
|---|---|---|
| A for loop with n = 5: how many trace rows, and what is total? | 6 rows and total = 15 | Five rows means the failing test was dropped; act one again |
| Halving 200 down to 1 takes how many steps? | 7 steps | Six means a step was skipped; act two again |
| Bubble sort on 8 items at worst, and binary search over 1,000? | 28 and 10 | Mixing the two means act three again |
09 Tutor FAQ
Which year is this for?
S5 Term 2 ICT, the programming section. S4 covered spreadsheet formulas and database queries, so this page turns program execution into a countable table before S6 data structures.
Can 45 minutes cover it?
It covers trace tables, for against while, nested counts and the two searches. Recursion and formal complexity notation need their own lesson; this page only uses powers of two.
Is there a matching paper?
Yes. Homework points to Question 3 parts 9 to 11 for tracing and Question 4 parts 13 to 15 for sorting and searching, which match the table and the counting formulas.
Find a tutor freeTutor sign-up →
©2026 TutorZone · www.tutorzone.com.hk · Terms of use · All rights reserved. Original TutorZone material for personal study and teaching only; not for resale or republication.



