Skip to main content

GCSE

Lesson 3 Tracing algorithms

Curriculum > KS4 > Unit > Lesson

For this lesson, learners will be shown examples of tracing a Python program and a flowchart. Trace tables are great for walking through an algorithm and are often used to locate logic errors. However, the focus of this lesson is mainly on using a trace table to understand how the algorithm works as this is what learners will use trace tables for in the coding searching and sorting algorithms lessons, which are lessons 6 and 9 of this unit respectively. That being said, there is a logic error in the second task of the worksheet for finding the lowest number in a list which learners will use a trace table to detect. The working code for all the algorithms is linked below. It is assumed that learners have already covered the lessons on selection, while loops, for loops, nested loops, and lists in the KS4 Programming unit. These concepts are essential to analysing and interpreting the code for the searching and sorting algorithms later on in this unit. Learners should also be familiar with calculating integer division and modulo in Python, which is covered in lesson 7 of the Programming unit. Integer division is key to the binary search program in this unit.

Learning objectives

  • Use a trace table to walk through code that contains a while loop, a for loop and a list of items
  • Use a trace table to detect and correct errors in a program

Package contents

  • Lesson plans
  • Learning graphs
  • Unit overviews
  • Activities
Log in to download

Not registered yet?

Create an account and get access to over 500 hours of free teaching resources.

GCSE revision

A comprehensive range of content and helpful practice questions are also available for this topic.

Help us make these resources better

Provide your feedback

Or email us at [email protected]